I wonder if anyone can offer some advice with this, or offer some other creative solutions !
I have a
servlet which once processed needs to return the user to a given
JSP page passing with it some variables.
I am currently using response.sendRedirect to send the user to the next page. I can pass my variables as GET querystring variables by appending them to the URL; but I dont really want to do that as I dont want to visually expose such things on the URL (I like neat URLs !!), and my target JSP has currently been written to handle POST variables (but I guess I could re-write that section if needed)
I could pass my variables as session variables, but again, I would need to re-write a couple of sections of my target JSP to pick them out.
Given that my JSP file is currently coded to read and respond to POST variables, I'd really like my servlet to pass variables to it in that way.
Is there a way to do this ?, or some other creative solution ?
The only 'creative' solution I can think of (and I dont like it) is to create a PrintWriter object from the response object within the servlet, and using the println method, create a HTML form whose action is my JSP file and method is post and which has hidden input fields being the variables I want to pass. Lastly, I output a bit of JavaScript to submit the form !
Yuck !
Any better ideas ?
Cheers
Nathan