This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes sesion code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "sesion code" Watch "sesion code" New topic
Author

sesion code

vivek sivakumar
Ranch Hand

Joined: Aug 09, 2001
Posts: 187
well im not at all getting this solved!!!
in my jsp page i have a button , onclicking the button the sesion should expire and the user should be automatically taken to the login page again . im giving the onClick javascript function here , pls advice..
onClick(){
window.alert("do u wanna go");
<% session.invalidate%>
window.open("...//index.html");
}
is this a valid one ???


SCJP, SCWD <br />A farmer learns more from a bad harvest than a good one.
Tony Alicea
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
Is your application for an Intranet where "the boss" dictates the HW platform, the particular browser to use and with what capabilities enabled (like javaScript), or is your application intended to be used in the public WWW?
If the answer is the public WWW, you should not expect universal JavaScript support by your clients.


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
vivek sivakumar
Ranch Hand

Joined: Aug 09, 2001
Posts: 187
for now we assume that javascript should be enabled!!
alicea just tell me if the code what i have written is correct or not???
Rehan Malik
Ranch Hand

Joined: Jul 09, 2001
Posts: 76
Yes it works

Rehan Malik
Vijay Kashyap
Ranch Hand

Joined: Jul 30, 2001
Posts: 74
It won't work the way you want it to be. As the scriplet tag <% session.invalidate() %> would be processed on execution of jsp hence the session would be invalidate in any case.
The best way be to open / forward to another jsp (on clicking the button)which would invalidate the session for you.
Regards,
Vijay
vivek sivakumar
Ranch Hand

Joined: Aug 09, 2001
Posts: 187
hi vijay,
exactly what u said had happened (i being a dumb was scrotching my head why this was invalidating all my jsp pages)!!
can u just explain things in a bit more detail on how to forward it to a specific jsp page!!!
Peter Kristensson
Ranch Hand

Joined: Jul 02, 2001
Posts: 118
change your code to this:

and the write the logout.jsp page:
<% session.invalidate %>
<jsp:forward page="...//index.html" />

Let me know if this works
/Peter
vivek sivakumar
Ranch Hand

Joined: Aug 09, 2001
Posts: 187
hi peter,
thanks for ur help , well it really works !!! but the thing is that i want to close the referring window (one which opens logout.jsp) do u have some idea how can i do this using javascript!!
hi vijay kashyap!
Thanks a lot for u also !
[This message has been edited by vivek sivakumar (edited August 20, 2001).]
Vijay Kashyap
Ranch Hand

Joined: Jul 30, 2001
Posts: 74
Vivek shivakumar,
One of the solution being to open the logout.jsp in the same frame, in this case you donot have to care about closing the window.

If you want to avoid JavaScript then you can submit the page on clicking the button and based on your requirement fwd it logout.jsp page.
Hope this helps.
Regards,
Vijay
 
 
subject: sesion code
 
Similar Threads
refresh a page
reloading a page
saesion
how to make js function call?
parent and child page - Refresh Problem?