Issue
What I'm trying to do here is to redirect to an html page with a form from servlet and as I redirect, is it possible to set values in a textfield of that form? Like the way I get the values from the form using request.getAttribute(), similarly is there a way to set values in a input element in an html form from a servlet? Would greatly appreciate your help, thank you.
Solution
Java does not provide method to set parameters in servlet. If you must do this using HTML here are two options:
(I still recommend using JSP)
1.display the registration page using PrintWriter#println()
in servlet.
response.setContentType("text/html");
out.println("blah blah blah");
out.println("<input name='username' type='text' value='"+javaVariable+"'");
out.println("blah blah blah");
2.In your HTML page make an AJAX call to servlet that returns data you need and populate form elements with this data.
Answered By - NAK