Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


javascript reset and jsp session.invalidate

Posted on 2002-07-09
Medium Priority
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>

<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>
Question by:schroom
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 33

Accepted Solution

knightEknight earned 400 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 ...


   // here put code to redirect somewhere

Author Comment

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

Author Comment

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

                     // 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.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Expert Comment

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

LVL 46

Expert Comment

ID: 7141052
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

Author Comment

ID: 7141098
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"

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

618 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