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!

[557 byte] By [MickyLianga] at [2007-11-27 1:24:26]
# 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.

appy77a at 2007-7-12 0:15:38 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...