session validation and invalidation
Hi,I have got a problem about the session.That's how to judge if a user has login in the jsp page(without scriptlet).
The codes structure might look like this:
...
//Check if the session scope has a 'userName' attribute
if(not hasUserName) then
<jsp:forward page="login.jsp"/>
...
Another question is how can I clear a session in the jsp pages(without scriptlet).
Any help is preciated.Thanks in advance!
# 1
> Hi,I have got a problem about the session.That's how
> to judge if a user has login in the jsp page(without
> scriptlet).
> The codes structure might look like this:
> ...
> //Check if the session scope has a 'userName'
> attribute
> if(not hasUserName) then
> <jsp:forward page="login.jsp"/>
> ...
You would need a lot more than a JSP page to judge if a user has logged in.
Take a look at the MVC design pattern , DAO pattern, JDBC tutorial.
>
> Another question is how can I clear a session in the
> jsp pages(without scriptlet).
> Any help is preciated.Thanks in advance!
The purpose of JSP pages is to display information so a number of features are limited intentionally especially if it is possible to perform those tasks in the application layer in Java Classes rather than cluttering JSP pages with non-display related code.
If you implement your application using MVC/ Front Controller design pattern then write the Java code to remove the session attribute in the Servlet class that gets called on navigating away from the JSP page.