Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Set browser language via a dropdown in javascript or via JSTL?

Posted on 2006-07-13
2
Medium Priority
?
1,847 Views
Last Modified: 2013-11-24
Is it possible to set a users browser language through javascript or using the JSTL?

I have a webapp that has been internationalized.  This works fine for english/spanish/french.

I want to be able to change the displayed language on the fly via a dropdown.  This dropdown would contain (english, spanish, french) and upon clicking one of these, the page would refresh and the new browser language would be set.

Is there a way to do this?  Can I take advantage of the app already being internationalized and change the language "on the fly" so to speak?

Thanks.
0
Comment
Question by:csciguy81
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
liviutudor earned 1500 total points
ID: 17100742
well the best way -- in my humble opinion -- is to have a session property for the user language. Then use a dropdown menu on each page so when the user changes it, you take another trip to the server and submit the new language value, store this in the session so then every time the user requests a page, you can check out the language s/he selected last and display the page using that language.
In other words, do it server side.
0
 

Author Comment

by:csciguy81
ID: 17102988
I ended up storing it in the session, but not doing the processing server side.  

Set an attribute called "locale" in the session, based on the users dropdown selection.

Run this on my page, and it works fine.
<%String language="";
if((String)session.getAttribute("locale")!=null){
      language=(String)session.getAttribute("locale");
}else{
      language="en";
}
%>
<fmt:setLocale value="<%=language%>"/>
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Starting up a Project

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question