• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

is this good for logout page

 
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Seriously? That's what you're going with? I prefer this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic