Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is this good for logout page

 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in my project i set many session varibles.
i write a log out jsp page and include it many pages.
here is my logout.jsp


is it ok?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
typically, if you ask question clearly, you get clear answer.

coming to your question, what happened when you clicked the *dead* button?. as a side note, avoid scriptlet in jsp which is consider as a bad practice


 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what do you mean dead button.
I need to do clear session varibles when click logout button.
is this ok?
 
Nicola Garofalo
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need to unbind all the attributes from the session on logout, don't you?
Well, you can write:



Look at HttpSession object API for further details
 
Nicola Garofalo
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyway that's not what's going to happen on your jsp.

In your jsp the button in useless, and you are removing attributes from the session

try to do like this:
In your jsp just write


Then you should write a servlet mapped in logoutservlet that invalidates the session

 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anyway it is ok.
i have another problem
is this both are same


 
Nicola Garofalo
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

They are not the same, it doesn't work like that.

sorry if i repeat it, you should execute logout operation in a servlet, not in a jsp.
Remember, your button is useless in the example you posted: session attributes there are removed in any case.

 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok
i did what you said.
but why you say
should execute logout operation in a servlet, not in a jsp


what is the wrong with it is doing in jsp?
 
Nicola Garofalo
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because that way of programming is cahotic.
You are doing too many things in one component. You are showing data and performing a key operation as a logout in one jsp.
Always try to keep your operations separated or your application can become really hard to mantain.

There's an architectural pattern called MVC that helps you to avoid such situations. As you will go on programming you will feel the need of following it, it will help you to keep components simpler, easy to mantain and to update, not coupled one to the other.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Samanthi perera wrote:what is the wrong with it is doing in jsp?
Everything!

Please read this article for information on modern best practices.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic