You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Esbrook, Scott" <Sc...@compuware.com> on 2003/03/12 21:40:43 UTC
RE: Locale object in session
Tarek,
I also have this requirement (no use of Session objects), and following
Craig's suggestions I had the same problem you did. It stems from the
following:
in class org.apache.struts.util.RequestUtils method
retrieveUserLocale(PageContext pageContext, String locale) {
if (locale == null)
locale = Globals.LOCALE_KEY;
Locale userLocale = (Locale) pageContext.getAttribute(locale,
PageContext.SESSION_SCOPE);
if (userLocale == null)
userLocale = defaultLocale;
return userLocale;
}
throws java.lang.IllegalArgumentException: can't access SESSION_SCOPE
without an HttpSession
at
org.apache.jasper.runtime.PageContextImpl.getAttribute(PageContextImpl.java:
217)
at
org.apache.struts.util.RequestUtils.retrieveUserLocale(RequestUtils.java:878
)
<snip>
I compiled a version of Struts locally (v 1.1 rc1), and changed the method
as follows:
retrieveUserLocale(PageContext pageContext, String locale) {
<snip>
Locale userLocale = (Locale) pageContext.getRequest().getLocale();
<snip>
}
This is working for me so far, though I do not make use of all the features
of Struts (ie, Validator, transaction tokens, Tiles, etc.). Hope this helps.
Scott
-----Original Message-----
From: Tarek M. Nabil [mailto:Tarek.Nabil@itworx.com]
Sent: Sunday, February 16, 2003 4:18 PM
To: Struts Users Mailing List
Subject: RE: Locale object in session
Thanks for the help.
I still get a "can't access SESSION_SCOPE without an HttpSession:
java.lang.IllegalArgumentException: can't access SESSION_SCOPE without an
HttpSession" exception.
I think the <bean:message> tag is the cause of this exception. I tried
looking in the reference, and I cannot find a way of making this tag search
for the Locale object in the session.
Please help.
Thanks
-----Original Message-----
From: Craig R. McClanahan [mailto:craigmcc@apache.org]
Sent: Saturday, February 15, 2003 11:57 PM
To: Struts Users Mailing List
Subject: Re: Locale object in session
You'll need to do several things:
* Set the "locale" servlet init parameter (on the controller servlet)
to "false".
* At the top of each JSP page, be sure to include:
<%@ page session="false" %>
so that JSP won't create a session for you
* If you use the <html:html> tag, use a locale="false" attribute
there as well.
Craig
On Sat, 15 Feb 2003, Tarek M. Nabil wrote:
> Date: Sat, 15 Feb 2003 21:51:30 +0200
> From: Tarek M. Nabil <Ta...@itworx.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: "Struts (E-mail)" <st...@jakarta.apache.org>
> Subject: Locale object in session
>
> Hi everyone,
>
> I'm using Struts 1.0.2.
>
> I noticed that whenever a new session is created, Struts creates a locale
object for that user and stores it in his session. I need to disable session
state in my application, so how can I prevent Struts from doing this?
>
> Thanks
>
The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org