Hi All,

I have developed a web application using jps. I have a user pages, which can be accessed after entering login credentials. If a user tries to go the a certain page directly without logging in, it directs to login page, this works perfectly in all browsers except mozilla.

I have created session in all pages and checking if session is null or not, but still the users goes directly without logging in into a page where login credentials required. This is a major problem in mozilla. How to overcome this problem. Any solution regarding this would be appreciated.

Thanks

Recommended Answers

All 4 Replies

Can you post code on how you redirect?

Can you post code on how you redirect?

Hi javaAddict,

This is how i redirect.

<%
try
{
String strSessionUser = session.getAttribute("regusername").toString();
}
catch(Exception e)
{
%>
<script>
adminhome.expmsg.value='Please login';
adminhome.action="index.jsp";
adminhome.submit();
</script>
<%
}
%>

Then try to see what is the value of regusername.

<%
String strSessionUser = session.getAttribute("regusername");
System.out.println("strSessionUser:"+strSessionUser );
if (strSessionUser == null) {
%>
  <jsp:forward page="index.jsp?expmsg=Please login" />
<%
}
<%

Maybe what you have in the catch doesn't execute the way you want it because each browser has small differences in the way they handle javascript. ...maybe

Instead of using javascript, you can use the RequestDispatcher class and write java code that redirects.

But most important check what is the value of strSessionUser when you think you should redirect

Hey Guys,

Thanks for your help. It works perfectly!!!

Hi javaAddict,

This is how i redirect.

<%
try
{
String strSessionUser = session.getAttribute("regusername").toString();
}
catch(Exception e)
{
%>
<script>
adminhome.expmsg.value='Please login';
adminhome.action="index.jsp";
adminhome.submit();
</script>
<%
}
%>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.