You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Neal Kaiser <ne...@makeastore.com> on 2001/03/13 15:13:20 UTC

Getting Locale from a non-struts servlet

Does Struts store the client's Locale in their session somewhere? If so, how
would
I access it?

I have a non-struts servlet which I want to try to pull the Locale object
from.

Thanks,

Neal


Re: Getting Locale from a non-struts servlet

Posted by Incze Lajos <in...@mail.matav.hu>.
I would be pleased if I would be able to specify a default local 
in web.xml for struts (as an init parameter). All the other ways
can be late to override the system/servlet-engine default locale.
(E.g. if you use the servlet container's authentication the user
can enter at many different places and it is simply annoying to
start every action with locale checking.)

Every user sessions could inherit this value unless they override
in the http header or in some programmatic way. I can't see any
drawback but test the idea before applying a feature request on
Bugzilla.                                                 incze

Re: Getting Locale from a non-struts servlet

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 13 Mar 2001, Neal Kaiser wrote:

> Does Struts store the client's Locale in their session somewhere? If so, how
> would
> I access it?
> 

Yes, it does.  Look for a java.util.Locale object stored as a session
attribute under key "org.apache.struts.action.LOCALE".  In a program, you
could use the symbolic string constant Action.LOCALE_KEY instead (from the
org.apache.struts.action.Action class).

Be sure that you enable Locale tracking if you want this to work, by
setting the appropriate initialization parameter for the controller
servlet (parameter "locale" should have a value of "true").  Also, if the
first request in your session is to a JSP page instead of the controller
servlet, you can have the page save the Locale by using tag:

	<html:html locale="true">
	... contents of your page
	</html:html>

around it.

> I have a non-struts servlet which I want to try to pull the Locale object
> from.
> 
> Thanks,
> 
> Neal
> 
> 

Craig McClanahan