Issue
Is it possible to create a servlet that let's the browser of the client stay in that particular page, while at the same time changing a value of a session wide variable?
Basically I have a button on my webpage, which is encapsulated in an form that calls an servlet on submit. On that servlet I now want to increase a counter for that session by 1, but I don't want the page of the client to change, in case the user wants to press the button several times.
How can I program the servlet to not send back a response to the user, or if that's not possible, how do I sent a response that basically says: Don't do anything, stay where you are.
I tried simply not sending the response with .forward(), but the browser is then stuck on a blank page. I also tried .setContentType(null), but still nothing. Is this even doable?
Solution
Do an AJAX call to that servlet in client's browser using XMLHttpResponse object like var xhr = new XMLHttpResponse()
just google about AJAX request
Answered By - Sri Madhan