You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Łukasz Piątkowski <lu...@e-direct.pl> on 2005/11/04 14:02:57 UTC

How to get ACCESS to Locale in TAG class

Hello !

    I have a problem with accessing LOCALE in my TAG class. When I want 
to get LOCALE in my ACTION class I use :

request.getSession().getAttribute(Globals.LOCALE_KEY) - and it works fine

in my TAG class I use :

pageContext.getSession().getAttribute(Globals.LOCALE_KEY) - it is null

This is the fragment of my code :
"if(pageContext.getSession().getAttribute(Globals.LOCALE_KEY)!=null)
                {
                    
loc=(Locale)pageContext.getSession().getAttribute(Globals.LOCALE_KEY);
                    lwriter.print("SESSION LOCALE");
                }
                else
                {
                    loc=Locale.getDefault();
                    lwriter.print("SERVER LOCALE");
                }
"
It always returning SERVER LOCALE :(

Please HELP !

Kind Regards, Lukasz


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to get ACCESS to Locale in TAG class

Posted by Hubert Rabago <hr...@gmail.com>.
Is your JSP being accessed directly?
If so, you may need to let the Struts RequestProcessor do its work first.

<action path="/myPage"
            forward="/myPage.jsp"/>

then access it the way you would other Struts actions: 
http://domain/myApp/myPage.do

Hubert

On 11/4/05, Łukasz Piątkowski <lu...@e-direct.pl> wrote:
> Hello !
>
>     I have a problem with accessing LOCALE in my TAG class. When I want
> to get LOCALE in my ACTION class I use :
>
> request.getSession().getAttribute(Globals.LOCALE_KEY) - and it works fine
>
> in my TAG class I use :
>
> pageContext.getSession().getAttribute(Globals.LOCALE_KEY) - it is null
>
> This is the fragment of my code :
> "if(pageContext.getSession().getAttribute(Globals.LOCALE_KEY)!=null)
>                 {
>
> loc=(Locale)pageContext.getSession().getAttribute(Globals.LOCALE_KEY);
>                     lwriter.print("SESSION LOCALE");
>                 }
>                 else
>                 {
>                     loc=Locale.getDefault();
>                     lwriter.print("SERVER LOCALE");
>                 }
> "
> It always returning SERVER LOCALE :(
>
> Please HELP !
>
> Kind Regards, Lukasz
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>