I am begginer in Servlet and JSP. In my project I have a modify form option that should get populated from the database as per the serial number searched. Then the user can modify the value in the form and it will go and override the same row in the database. The problem is I am able to retrieve the value in resultset in servlet but I am not able to set those values to the desired form fields in JSP i.e. I m not able to access result set in JSP. Please someone help me. Thanks in advance.
Asked
Active
Viewed 296 times
-2
-
Build a List of DTO in your servlet based upon the resultset – Scary Wombat Nov 02 '16 at 08:18
2 Answers
0
Populate List
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {Obj obj=new Obj(); // Your bean object obj.set(rs.getString("fieldName")); list.add(obj); }
request.setAttribute("resultList", list);
JSP Page : Use jstl
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <c:forEach items="${resultList}" var = "row" > row.fieldName </c:forEach>

Waqar
- 428
- 4
- 17
-
Sir, i don't know how to use jstl in JSP page coz i am beginner in this. can u plz share the full code to set the value in text field. thanks in advance – Jyoti Ranjan Singh Nov 02 '16 at 08:28
-1
You can add that resultset
in session when you got that in servlet. and on JSP you can access that from session
and set the values in value
property of input tags on your JSP, for this you can go through the below link.

Community
- 1
- 1

Umais Gillani
- 608
- 4
- 9