clear session history and display the page again

I have a jsp page (out.jsp) wich contains a form with submit button. When "submit" is clicked, out.jsp calls a java servlet (controller.java) which then performs some operations and the results are again displayed by out.jsp. I track session history with HttpSession(inside controller.java) and display it each time "submit" button is pressed. In other words, I display all previous paramters the user selected. I need to create a "clear history" button. I guess I can try to use session.removeAttribute inside the servlet but I don't know how I would know which button was pressed (submit or clear?)

So, my question is in which file (out.jsp or controller.java) and how  I would create a function for clearing history, so that out.jsp is displayed again but without session history displayed.
na77Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

objectsCommented:
set a value for your button, and check it in your servlet
or have the button call a different servlet
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sompol_kiatkamolchaiCommented:
Or you can have a hidden field name "action"

<input type="hidden" name="action">

and when you click submit or clear you have to set it value by javascript to "submit" or "clear"
and then in servlet use request.getParameter("action") and check whether it is submit or clear.
0
bloodredsunCommented:
Just make the clear button a link to the controller with the parameter clear as you aren't submitting any form info.

e.g.

controller.do?action=clear

Then in controller, check params and then if the sction is clear, call session.invalidate() to destroy session then create a new sesion with request.getSession(true) and forward back the the out.jsp page.
0
bloodredsunCommented:
I'm easy but I gave them the code required to kill the session so that's at least part of the solution...
0
sompol_kiatkamolchaiCommented:
I think I answered the question too.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.