This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes JSP and the fly likes reset button and clearing sessions Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSP
Reply Bookmark "reset button and clearing sessions" Watch "reset button and clearing sessions" New topic
Author

reset button and clearing sessions

mary morris
Ranch Hand

Joined: Mar 16, 2002
Posts: 97
I have the following small form (really much larger)I need to be able to clear the session variable that have been (or will be added) added.
<html><head><title>Untitled</title></head><body>
<form name="pensionBenefits" method="post" action="servlet/x.y"
onSubmit="return validateForm(this);">
<input type="text" name="AveSal" size="9" >
<script language="JavaScript">
<!-- // Begin
function clearForm() {
with (document.pension) {

AveSal.value = '';
} // end with
}
//--></script>
<a href="javascript:clearForm();"><img src="images/butn-reset-e.gif" border="0" alt="Reset"></a>
</form></body></html>
I know I need to use
<% session.invalidate(); %>
or session.removeAttribute
,but I am not clear on the exactly where to put it
Thanks, for any help
Imran Ahmed Khan
Greenhorn

Joined: May 01, 2002
Posts: 5
Well please clearify your question first ... I cant figure out that where u have to clear the session and why?
You want to clear the session when u enter this page or when u are about to leave this page ???
One for thing i want to add that if ur cookies are not enabled then session whould not work, so please do check your browser configuration also using session.invalidate(); sometimes doesnot remove attributes from the session so it is a good practice to use session.removeAttribute(...); function explicity to remove attributes from the session .


SCJP2 , SCWCD
mary morris
Ranch Hand

Joined: Mar 16, 2002
Posts: 97
Imran,
Thanks for your reply and information. I have a couple of forms that get sent to a servlet, calculations are done and the information is available in the session, this all works fine. But I just want to be able to reset the form fields, just as a normal (html) reset does,not end the session, at this time, but they may want to update or change the data, hit submit and get a new set of calculations.
so..
AveSal.value = '';
would become?
<%=session.removeAttribute("AveSal") %>
??
Faraz Ahmed
Greenhorn

Joined: Mar 26, 2002
Posts: 10
I get your point ...
Well if u want to give an option for resent den u should explicitly remove the attributes that the servlet set using:
session.removeAttribute("Avgsal");
Well mary if u r having any futhur problems resenting the session then plz do ask again and again until u r dont solving them.


OCP, SCJP2, SCWCD
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: reset button and clearing sessions
 
Similar Threads
need help clearing fields
java Script Program
Check a checkbox after hitting a reset button
javascript problem
how to access values in session from javascript