| Author |
is this good for logout page
|
Samanthi perera
Ranch Hand
Joined: Jan 08, 2010
Posts: 510
|
|
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
Joined: Jan 28, 2008
Posts: 5575
|
|
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
Joined: Jan 08, 2010
Posts: 510
|
|
what do you mean dead button.
I need to do clear session varibles when click logout button.
is this ok?
|
 |
Nicola Garofalo
Ranch Hand
Joined: Apr 10, 2010
Posts: 308
|
|
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
|
Bye,
Nicola
|
 |
Nicola Garofalo
Ranch Hand
Joined: Apr 10, 2010
Posts: 308
|
|
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
Joined: Jan 08, 2010
Posts: 510
|
|
anyway it is ok.
i have another problem
is this both are same
|
 |
Nicola Garofalo
Ranch Hand
Joined: Apr 10, 2010
Posts: 308
|
|
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
Joined: Jan 08, 2010
Posts: 510
|
|
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
Joined: Apr 10, 2010
Posts: 308
|
|
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
Joined: Jan 10, 2002
Posts: 56185
|
|
Samanthi perera wrote:what is the wrong with it is doing in jsp?
Everything!
Please read this article for information on modern best practices.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
 |
|
|
subject: is this good for logout page
|
|
|