Solved

javascript reset and jsp session.invalidate

Posted on 2002-07-09
6
2,701 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
Comment Utility
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
Comment Utility
Thanks knightEknight ,
I will try what you have posted and get back to you soon.
Thanks
0
 

Author Comment

by:schroom
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 1

Expert Comment

by:steve-e-b
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now