You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Craig Laverty <dl...@bigpond.net.au> on 2002/05/31 19:32:20 UTC
Request for an example for getting the locale from a struts taglib
Hi,
Can someone show me a quick example of how to display the users locale in a
jsp using one of the struts taglibs?
I know that the locale is in the request but am not sure how to access it.
Did you know that searching for bean or taglib in the
http://www.mail-archive.com/struts-user%40jakarta.apache.org/ produces 0
results? Obviously they have a filter on the words that would produce too
many results. Kind of hampers those searching for struts taglib examples.
Is there another mail archive site that anybody would recomend?
Thanks
Craig.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Request for an example for getting the locale from a struts taglib
Posted by ajTreece <aj...@sun.com>.
I know that scriptlets are a no-no, but here is how I got it to work. I'm using
tiles so this code is processed in the tile that is common to every page every page.
<%@ page contentType="text/html; charset=UTF-8" language="java"
import="java.util.Locale,org.apache.struts.action.Action" %>
<%
String useragent = (String)request.getHeader("User-Agent");
Locale locale = (Locale)request.getLocale();
String myLocale = locale.toString();
request.getSession().setAttribute(Action.LOCALE_KEY,locale);
%>
The useragent string is used a little farther down to determine the version of
Netscape and Internet Explorer so I can include the correct style sheet for that
browser.
Hope this helps. I couldn't get languages to work consistently until I included
this code.
Later, ajTreece
Craig Laverty wrote:
> Hi,
>
> Can someone show me a quick example of how to display the users locale in a
> jsp using one of the struts taglibs?
>
> I know that the locale is in the request but am not sure how to access it.
>
> Did you know that searching for bean or taglib in the
> http://www.mail-archive.com/struts-user%40jakarta.apache.org/ produces 0
> results? Obviously they have a filter on the words that would produce too
> many results. Kind of hampers those searching for struts taglib examples.
> Is there another mail archive site that anybody would recomend?
>
> Thanks
>
> Craig.
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Request for an example for getting the locale from a struts taglib
Posted by Craig Laverty <dl...@bigpond.net.au>.
>> I know that the locale is in the request but am not sure how to access
it.
>request.getLocale();
>-Vincent.
Thanks.
<%=request.getLocale()%> works great.
Craig.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Request for an example for getting the locale from a struts taglib
Posted by Vincent Aumont <vi...@vsl.ca>.
> I know that the locale is in the request but am not sure how to access it.
request.getLocale();
-Vincent.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>