Register / Login
this forum made possible by our volunteer staff, including ...
Stephan van Hulst
Globally change session language (JSTL) through a servlet
Nick White Ro
posted 9 years ago
I have a web application that uses JSTL for localization.
I want to be able to change the session language everywhere in the application.
For this, I use a
that is called by this url:
This is what the servlet does:
// This is the attribute name that currently works. String sessionLangAttribute = "javax.servlet.jsp.jstl.fmt.locale.session"; String lang = request.getParameter("lang"); request.getSession().setAttribute(sessionLangAttribute, lang); String previousURL = request.getHeader("referer"); // Go back to the page from which it came. response.sendRedirect(previousURL);
It works just fine, but I'm not sure if that session attribute is always the same, or it's implementation specific.
It would be better if I used the constant that holds that name.
So far, looking through the API, I only found
, which has the value "javax.servlet.jsp.jstl.fmt.locale", but using that doesn't change the language.
It is sorta covered in the
JavaRanch Style Guide
Boost this thread!
Scripting with JSTL Core tags.
[i18n tiles] difference btw locale and lang
Problem running JSP with Resin
populate items using struts2 <s:select>
I get exception : Path http://www.mywebsite.com/ does not start with a "/" character