Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

reset button and clearing sessions  RSS feed

 
mary morris
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
mary morris
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!