Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Session Attribute Problem. Doesn't work properly on remote server.

843840Oct 8 2009 — edited Oct 10 2009
Hello!
I'd be very pleased if you could help me.
My application uses session.getAttribute() and session.setAttibute(). It works properly on my local (developer's) computer. When I transfer my project into remote server session attribute doesn't work. getAttribute() returns null. Both machines work on Windows platform, Tomcat 6. Here is my code:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	String par = request.getParameter("lang");
	if (par != "")
	{
		HttpSession session = request.getSession(true);
		session.setAttribute("language", par);
	}
	response.sendRedirect(request.getHeader("referer"));
}
HttpSession session = request.getSession(true);
if (session.getAttribute("language") != null)
{
	Locale l = new Locale((String) session.getAttribute("language"));
	String lang = l.getISO3Language();
        String file = sc.getRealPath(uri + "index-" + lang + ".jsp");
        if (log.isDebugEnabled()) {
    	      log.debug("Trying: " + file);
        }
        File f = new File(file);
        if (f.exists()) {
    	      return uri + "index-" + lang + ".jsp";
        }
}
I'd like you to advise me what I should change to make it work. May be any settings in server.xml, context.xml? Cookies?
Thanks in advance.

Best regards,
Pavel
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 7 2009
Added on Oct 8 2009
15 comments
2,543 views