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.
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
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
posted
0
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") %> ??
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.