Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3358
  • Last Modified:

javascript reset and jsp session.invalidate

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>

<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>
1 Solution
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 ...


   // here put code to redirect somewhere
schroomAuthor Commented:
Thanks knightEknight ,
I will try what you have posted and get back to you soon.
schroomAuthor Commented:
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

                     // 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.
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Try targetting the endMySession.jsp into a hidden frame or sending it to a popup window that displays a confirmation message.

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

if request.form("Reset") = "Reset" then
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
schroomAuthor Commented:
Thanks everyone for your help.

 <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.
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"
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now