session "lost"?

i have two pages, one 'alogin.jsp' which validates login infomation, and 'adminhome.jsp' where user are redirected when login is successful and session variable is set. If someone is at adminlogin.jsp and he does not have a valid session he is redirected to the login page.

alogin.jsp

session.setAttribute("id",admin);

session.setAttribute("dpass",dpass);

response.sendRedirect("adminhome.jsp");

adminhome.jsp

<%@ page session="true" %>

<%@ page import="java.io.*" %>

<%

if (session.getAttribute("id")==null || (!session.getAttribute("id").equals("administrator")))

response.sendRedirect("adminlogin.jsp?code=Please%20login%20to%20view%20that%20page!");

%>

Viewing the pages through http://localhost:8080/.. is ok, all pages works fine, but if I am viewing it through proxy server (http://205.123.12.3/..) The problem I am facing now is that my login is successful, but when it redirects me to adminlogin.jsp, the session somehow gets invalidated, or it's not set at all. Anyone knows how to go about troubleshooting this?

Any help is greatly appericiated.

[1253 byte] By [noelonarda] at [2007-10-2 6:19:31]
# 1
Try using <jsp:forward> instead of sendRedirect().I think this will solve the issue.. Try it ..
Ananth_Chennai_Indiaa at 2007-7-16 13:21:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

thanks, it works, but only for one page. any other subsquent pages that requires an administrator id in session is null or invalidated. is there a way to set a global session attribute?

anyway this issue exist with IE. i tried it with mozilla firefox and it works fine. why is this so? my friends said it could be due to dns issue. any feedbacks?

noelonarda at 2007-7-16 13:21:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Is cookies enabled in IE? And if you redirect the client, does he get redirected to the same host?
serlanka at 2007-7-16 13:21:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
put the values in application scope instead of session scope, if u want the whole application needs to use.
Ananth_Chennai_Indiaa at 2007-7-16 13:21:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

You are right it will work fine with mozilla and not with IE. Because whenever you open a new IE explorer window a new process will be created. And for every new Process a new session object will be created. But mozilla dosent create a new process whenever you open a new window. It will have the same process running but there will be several child processes that is why they can all get access to the same sesssion object.

qatadaa at 2007-7-16 13:21:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...