Aim: Want to display the result which is fetched from database table into resultpage(response.jsp)
index.jsp > servlet > output.jsp
After a submit button in index.jsp , it calls the below servlet page.and below code succesfully fetches the data from database. not i wanting to know the ways that i can display the data into response.jsp(output page)
Servlet:
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
int weeknum;
RetouchClass retouch = new RetouchClass();
weeknum = Integer.parseInt(request.getParameter("weeknum1"));
//weeknum
ResultSet weekNumResult = retouch.weekNum();
request.setAttribute("result", weekNumResult);
request.getRequestDispatcher("response.jsp").forward(request, response);
}
java Class
public RetouchClass() {
try {
connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
} catch (Exception e) {
e.printStackTrace();
}
}
public ResultSet weekNum() {
try {
retouchQuery = connection.prepareStatement("SELECT * FROM RETOUCH LIMIT 1 , 10 ;");
resultSet = retouchQuery.executeQuery();
} catch (Exception e) {
e.printStackTrace();
}
return resultSet;
}
Response.jsp
<table border="1">
--- Want here to display the data from resultset
</table>
- Thanks -Sathish .