Solved

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

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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 124
ejb example issues 3 51
SequenceInputStream example 3 21
what is the best Integrated development environment 2 35
A short article about problems I had with the new location API and permissions in Marshmallow
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

740 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