tags:

views:

341

answers:

2

Hi,

I am trying to clear everything on my HTML form when I link back to it from a hyperlink.

Any ideas? My development language is java.

A: 

are you using session-scoped data? if so, close your browser and open it again.

Zack
or programmaticaly close the session :)
Olivier
I'm not sure if he's talking about from a user's perspective or a developer's perspective
Zack
oh sorry...i meant from a development perspective
How would you guys clear all the contents of a HTTP session programatically?
What are you using ? Regular Servlet ? A Web Framework ?
Olivier
Regular Servlet
Is this question even worthy enough to post?
A: 

I'm not sure the application is, but one way to accomplish this would be to use JavaScript. For example, if it is acceptable to clear the form every time that page is visited you could write a quick function that clears the form when the page is loaded (i.e., using the onload event).

If you only want to clear the form when the page is hit from that link you could add a param to the URL (e.g., clearForm=true) and use JavaScript to pick up the query string and clear the form when that parameter is present.

This is, of course, a purely client-side solution. For a server-side solution it would be helpful to know what framework you are using.

Marcus
I actually added three lines of code to one of my jsps and it seems to be working fine. I am calling the invalidate method of httpsession which clears the session when the application reaches that particular jsp...