Issue
I am trying allready more than 2 Days to find out how to place response from Servlet to the particular position of an HTML page. Location should be at the place where "Here I want to be!!!" is
<form name="input" action="ExamServlet" method="get">
<table>
<tr>
<th>Nr.</th>
<th>"Here i want to be!!!"</th>
</tr>
<tr>
<td>3+1=4?</td>
<input type="submit" value="Einreichen">
</form>
The doGet method from servlet is here:
PrintWriter pwritter=response.getWriter();
pwritter.print("here i am ");
RequestDispatcher dis=request.getRequestDispatcher("Exam.html");
dis.include(request, response);
And as most of experienced programmers would notice, i am getting the value "here i am " above the html table.
to be more precise with the question:
Is it at all possible what i want by using only servlets and HTML? If yes, small hint would be perfect! If not, should i use JavaScript? I would prefer without it...
Thanks in Advance!! Der Kerl
Solution
Try first put in output stream part of html before place where you need input your data:
pwritter.print("<form name="input" action="ExamServlet" method="get">" +
"<table>"+
"<tr>"+
"<th>Nr.</th>"+
"<th>");
then put there your data:
pwritter.print("here i am ");
then put what is left from static html.
pwritter.print("</th>"+
"</tr>"+
"<tr>"+
"<td>3+1=4?</td>"+
"<input type="submit" value="Einreichen">"+
"</form>");
and then do dis.forward(request, response);
Answered By - Alex A.