I am new to Java servlets and JSP...
I have created a Java servlet. Actually this is my first servlet I am working on!
Inside of my servlet code, I have a loop. For each iteration of this loop, there are variables that will be set to different values. After each iteration of this loop ends, I want to be able to print out my variables (these variables will change with each iteration of the loop) in a HTML table as a row....
After doing some research, it seems that I need to use a JSP page to output the variables in HTML. However, how can I send my data to the JSP page after each iteration of my loop?
pseudocode example:
--servlet logic
forloop{
var1 = "somedata";
var2 = "somemoredata";
}
--jsp logic
//this part should only output once
<table>
<thead><tr><th></th></tr></thead>
//this part needs to output everytime the JSP is called. And each time, different values of var1 and var2 will be passed
<tr>
<td>${var1}</td>
<td>${var2}</td>
</tr>
</table>
Does anyone know the best method to do this? If I am going about this the wrong way, is there another approach I should take? Should I use AJAX to continue feeding information to update my page?
Thank you for any advice and insights!