Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session handling in java

 
Anand Sivathanu
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you were asked this question, can you share the answer you provided with us?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15366
40
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Anand Sivathanu
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the use-case for filters. See The Oracle Tutorial on the subject.
 
Anand Sivathanu
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Steve Luke

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

am i right?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic