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 ?
A redirect always elicits a GET request from the client. The HTTP protocol defines that. So you can't make it a POST. But why not just store your data in the user's session?
Joined: Aug 18, 2004
Yeah, I can see how session variables will work for me, but I'll need to re-work some of the JSP to pick up the session vars - its already written to pick up the POST vars (which will need to stay as other JSP pages submit POST vars from a HTML form to it); so I will need to add code to make it read and process session vars as well.
I guess my hope was that I could send POST vars from a servlet, and therefore not have to change code on a page that already works
Never mind !!
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Creating post variables with response object