• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

reset button and clearing sessions

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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") %>
??
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I AM MIGHTY! Especially when I hold this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic