I have a control servlet that forward the request to the model servlet.The model servlet retrieves results from a database and forward the display to the jsp.how do i display the result set in the jsp?Do i need to write the sql statement again in the jsp?
Asked
Active
Viewed 1,990 times
2
-
Duplicate of http://stackoverflow.com/questions/1808900/fetching-the-data-from-data-base-by-using-jsp, http://stackoverflow.com/questions/1831053/displaying-multiple-records-by-using-resultset, http://stackoverflow.com/questions/384189/how-do-i-make-a-java-resultset-available-in-my-jsp, http://stackoverflow.com/questions/2280034/jsp-helper-class-for-printing-content, etc..etc.. – BalusC Nov 15 '10 at 16:30
1 Answers
0
No, you use the request attributes map to pass data from the controlling Servlet to the JSP page.
Example. Controller Side:
void doGet(HttpServletRequest request, HttpServletResponse response)
{
List<String> names = Model.getNamesFromDB();
request.setAttribute("names", names);
// forward to JSP follows
...
}
Example. JSP page:
<%
List<String> names = (List<String>)request.getAttribute("names");
// do whatever you want with names
%>

Pablo Santa Cruz
- 176,835
- 32
- 241
- 292
-
I have my controller and model servlets done and mapped ,the problem now is what i need to write in the jsp to show the database results.I have tried it something like this but is not working: <%
${customerList.ID} ${customerList.Name} ${customerList.Address}