Click to See Complete Forum and Search --> : Sending session from servlet to form


runekje
10-24-2003, 12:49 AM
Hi

I have made a html-form with values that is submitted to a servlet. I then validate the values in the servlet and put them in a HTTP-session. If some values are invalid, I want to redirect the user back to the form with the session-values, and use them to fill in the values that were correct. But i don't know how to access the values in the session that is sent back to the form. I have tried to send the session from the servlet like this:

request.getSession.setAttribute("name" request.getParameter("name");

//Forward request to input-form
RequestDispatcher disp = this.getservletContext.getRequestDispatcher("form.htm");
disp.forward(request, response);

I would really appreciate it if someone could help me with this.

Khalid Ali
10-24-2003, 08:32 AM
Is your form created by Servelt ???

if so then its simple you can re creates it with fields popluated.
Otherwise,HTTP does not have any thing to realise that you are sending an Object of type Session for the HTML page to process it.

What you can do is redirect the page to form.html and append the values in
fieldnam=value
pairs and then in the form html use JavaScript to parse the url and fill the values.