aspose file tools*
The moose likes JSP and the fly likes session handling in java 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 handling in java" Watch "session handling in java" New topic
Author

session handling in java

Anand Sivathanu
Ranch Hand

Joined: Jun 25, 2010
Posts: 76
Hi Friends,

I have a doubt regarding session.I have been asked a question in such a way that

"I have 5 jsp pages. I donot need to handle session in each jsp pages. how do it?".

Please share your answers.

Regards,
Anand
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Since you were asked this question, can you share the answer you provided with us?


Steve
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14269
    
  21

Can you explain the question in more detail - the way you've written it now, it's very unclear what the actual question is.

"how do it?" - how do what exactly?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Anand Sivathanu
Ranch Hand

Joined: Jun 25, 2010
Posts: 76
@Steve Luke @Jesper de Jong

Thanks for your reply.

Let me explain what they asked

there are four JSP pages. how to handle session in JSP?

I replied

To check on each jsp page.

If session.getAttribute("user") is null, redirect to some other page,displaying "session expired".

But they do not want to edit each JSP page,by adding session.getAttribute on the top of JSP page.

So I replied, include a JSP that have session.getAttribute code(use include tag), on top of the four JSP page.

But they donot want to include that JSP also.

Here I have no answer to reply.

Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

This is the use-case for filters. See The Oracle Tutorial on the subject.
Anand Sivathanu
Ranch Hand

Joined: Jun 25, 2010
Posts: 76
@Steve Luke

Oh. you are telling about intercepting filters. To ensure the "logged user" not null for each request hit

am i right?
 
 
subject: session handling in java