Jason Lea wrote:

Ruth, Brice wrote:

This seems like a good idea, but I think it would prevent the country code from always being available in the URL (so if you're in the US site, you should always see /US/index.do, etc.) unless I can do this within the Tomcat/Servlet interaction, w/o issuing a redirect to the browser?! Can chain.doFilter() send the request to an action other than what was initially invoked by the browser?


Yes, the filter catches the request before it is passed to the servlet so you can do pretty much anything you like including sending the request to a different action. But the redirect is usually server side, so the browser would see the original URL.

So the problem comes back to getting the links to include the country code.

Here are 2 ways...

1. (probably involves the most work) Create some new JSP tags using the Struts tags a base. You need to do almost the same thing but insert that country code at the start of the link. Then you can use <myhtmltag:link action="/crafts/crafts">some text</myhtmltag:link>, which would create a link with url '/US/crafts/crafts.do'

2. (this might work staight off, and doesn't look too bad) Using JSTL and the Struts-EL tags...
<html-el:link page="${locale.country}/crafts/crafts.do">some text</html-el:link>


Though i think struts puts the locale into the session under the name |'org.apache.struts.action.LOCALE', so you might| need to put a copy (in your filter)
into session under a shorter name - or even just the country code that you are using. Eg put into session as 'urlprefix' and <html-el:link page="${urlprefix}/crafts/crafts.do">


The only thing you are losing here is you are not linking to the action name ('crafts/crafts'), you have to link to the url name 'crafts/crafts.do'. So if you changed the servlet mapping from '*.do' to '/do' you would have to change the links.

#2 is what I have currently implemented. Though the way that some other aspects are going, I may end up creating my own extension of the Struts HTML tag set for other reasons, at which point, I'll probably go ahead an implement #1.


Thanks for the excellent feedback!!

Brice

--
Brice D. Ruth
Sr. IT Analyst
Fiskars Brands, Inc.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to