Solved

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

Posted on 2006-07-13
2
1,843 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 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
A solution for Fortify Path Manipulation.
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 …
Simple Linear Regression

623 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