Solved

javascript reset and jsp session.invalidate

Posted on 2002-07-09
6
2,836 Views
Last Modified: 2007-12-19
THis is a javascripte and JSP question.
I am not sure of the syntax for ending the session on a JSP page, that is form.

That is instead of using a straight reset button, and clearing the form fields, I am trying to end the session using a reset button>

<%
session.invalidate();
<a href="#" onClick="document.pensionBenefits.reset(); return false"><IMG src="images/butn-reset-e.gif" width="73" tabindex="28" height="18" border="0" alt="Reset" align="bottom" ></a>
%>
0
Comment
Question by:schroom
6 Comments
 
LVL 33

Accepted Solution

by:
knightEknight earned 100 total points
ID: 7140945
you are trying to execute server functionality on the browser, which you cannot do.  You will have to do something like this:


<a href="endMySession.jsp" ><IMG src="images/butn-reset-e.gif" width="73" tabindex="28" height="18" border="0" alt="Reset" align="bottom" ></a>

and the content of endMySession.jsp would be ...

<%
   session.invalidate();

   // here put code to redirect somewhere
%>
0
 

Author Comment

by:schroom
ID: 7140964
Thanks knightEknight ,
I will try what you have posted and get back to you soon.
Thanks
0
 

Author Comment

by:schroom
ID: 7141015
I tried your suggestion, and it didn't seem to work. The reset button is clicked and the go to the endMySession.jsp, which has the
<%
                     session.invalidate();

                     // I just refreshed the page, but he session is still there.
                   %>

<a href="endMySession.jsp" ><IMG src="images/butn-reset-e.gif" width="73" tabindex="28"  height="18" border="0" alt="Reset" align="bottom" ></a>

Is there a way to clear the session without leaving the page, as they will will what to refill the form after resetting it.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 1

Expert Comment

by:steve-e-b
ID: 7141048
Try targetting the endMySession.jsp into a hidden frame or sending it to a popup window that displays a confirmation message.

Steve
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 7141052
Perhaps you can put some conditional logic at the top of the page--something like:

if request.form("Reset") = "Reset" then
   session.invalidate
end if

That way, when the user clicks on the reset button, it returns him/her to the same page with the form with a terminated session.

Fritz the Blank
0
 

Author Comment

by:schroom
ID: 7141098
Thanks everyone for your help.
using:

 <a href="endMySession.jsp" ...
where I have the below (added the response stuff, it has cleared the session.
I can then use the referrer to get back to my form.
<%
     session.invalidate();
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>
and going to <a href="endMySession.jsp"
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question