aspose file tools*
The moose likes JSP and the fly likes Session variables in Netscape 4.76? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Session variables in Netscape 4.76?" Watch "Session variables in Netscape 4.76?" New topic
Author

Session variables in Netscape 4.76?

Kumaran Sowrirajan
Ranch Hand

Joined: Oct 15, 2001
Posts: 36
Hi Friends
I need a solution for this doubt...
I am having 2 jsp files called file1.jsp and file2.jsp.
In file1.jsp i am getting the userid and password from the login page and stored that values in session variables.
If i click the submit button in file1.jsp page it will goes to next page file2.jsp there i am doing some validation based on the UserId and return back to the file1.jsp page and show the results to web user.
Here in file2.jsp what i am doing is i put the variables [userid and password] in Session like and redirect to the file2.jsp page for processing and validating some other conditions based on userid.
storing the values using session.setAttribute("name","value");
fetching the values using session.getAttribute("name"); methods.
Then from file2.jsp i am redirecting to the file1.jsp using response.sendRedirect() method to show the results.
here is the problem for me only in netscape4.76
If i use the response.sendRedirect() method from file2.jsp then the values in the session variables will be lost. But the same code is exactly working IE5.0 and above and even in Netscape 6.0.
But if i use the jsp:forward method instead of response.sendRedirect() method then mine code is working in netscape.can any of you knows the exact problem.what i am doing wrong here???
I gave both the absolute path as well as the relative path in the response.sendRedirect() method as a parameter.
Remember the same code is working in IE and in Netscape Navigator 6.0 but not in Netscape Navigator 4.76.
Thanks
Kumaran.S
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi kumaran
can u post ur code that can help to c what exactly r u having?
'coz it seems it should work regadless of any browser if u r having something in Session and then using response.sendRedirect()....tho we can never trust browsers
regards
maulin
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi again!

also if u r JUST 'VALIDATING' the user based on his/her id/password then y don u create a stand alone class and use it in ur file1.jsp? (i mean if u r not gonna display anything from file2.jsp to the user then one can think of this solution..)
regards
maulin
Kumaran Sowrirajan
Ranch Hand

Joined: Oct 15, 2001
Posts: 36
Hi
The code submitted below is working in Netscape 6.0 also but not in Netscape 4.76???
Herewith i am sending the example code....if i am using response.sendRedirect() in the place of <jsp:forward>? then the session variable gives a null value in the next page if i use response.sendRedirect() method.
<%@ page import="java.sql.Connection" %>
<jsp:useBean id="val" scope="request" class="Gov.Cdc.Dbmd.Lits.validatebean"/>
<%
String username = request.getParameter("username");
String password = request.getParameter("password");
//Checking the username and password is null
if(username == null || password == null || (username.trim()).length() == 0 || (password.trim()).length() == 0)
{
%>
<jsp:forward page="login.jsp">
<jsp aram name="msg" value="1" />
</jsp:forward>
<%
}
else
{
//Check whether the Driver is already Installed in your Hard Disk.
boolean check_flag = val.checkDriver();
if(!check_flag)
{
%>
<jsp:forward page="login.jsp">
<jsp aram name="msg" value="5" />
</jsp:forward>
<%
}
//Check whether the Database Connection created was Valid for the web user.
boolean connection_flag = val.createConnection(username.trim(),password.trim());
if(!connection_flag)
{
%>
<jsp:forward page="login.jsp">
<jsp aram name="msg" value="4" />
</jsp:forward>
<%
}
//Check if the user id exists in the database.
int count = val.checkuser(username);
if(count == 0)//User Id does not exists
{
%>
<jsp:forward page="login.jsp">
<jsp aram name="msg" value="1" />
</jsp:forward>
<%
}
else//User Id Exists
{
int user_status = val.getUserStatus();
if(user_status == 0)//Inactive User
{
%>
<jsp:forward page="login.jsp">
<jsp aram name="msg" value="6" />
</jsp:forward>
<%
}
else if(user_status == 1)//Active User
{
session.setAttribute("username",username.trim());
session.setAttribute("password",password.trim());
session.setAttribute("sessionid",session.getId());
int admin_status = val.getAdminStatus();
if(admin_status == 0)//Ordinary Web User
{
%>
<!-- The Problem is here....--><jsp:forward page="linelistreport.jsp" />
<%
}
else if(admin_status == 1)//Web Admin User
{
%>
<!-- The Problem is here....--><jsp:forward page="user_settings.jsp" />
<%
}
}
}
}
%>
Hi Just now i saw one more thing....
if i am using response.sendRedirect() method then the session variable value will be lost giving null value so in next page it will automatically take me to first login page.then once again if i enter the same userid and password then now the session variable is having the values userid and password it will go the exact destination page.
what i am doing wrong in this code.can you tell me???
[ June 25, 2002: Message edited by: Kumaran Sowrirajan ]
Balaji Munuswamy
Ranch Hand

Joined: Apr 07, 2002
Posts: 37
Sesssion value became null if cookies are disabled.
so use encodeRedirectURL() to redirect.I think it will solve your problem...

With Regard,
Balaji.M
Kumaran Sowrirajan
Ranch Hand

Joined: Oct 15, 2001
Posts: 36
Hi friends
Regarding the problem mentioned above...i didnt delete the cookies also even if i use the response.encodeRedirectURL() methos till the session variable shows the null value.
Finally i found one thing...if i specified the port number in the url to access the page then the session varaible value shows null.if i didnt mentioned the port number then the session value shows the exact value and redirected to the exact destination page.
like this....
http://localhost:80/test/test.jsp
it will not work in netscape 4.76
http://localhost/test/test.jsp
the above url is working fine
Can you tell me what i am doing wrong in that code?
Cheers
Kumaran S
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session variables in Netscape 4.76?