Reputation:
I am retrieving data from database in JSP in a result set. ResultSet in not empty but it is not displaying data in html tags, i.e. h3 is empty
ResultSet rs = null;
String sqlStr;
sqlStr = "SELECT * from IDEAS";
Statement stmt = con.createStatement();
rs = stmt.executeQuery(sqlStr);
<% while (rs.next()) { %>
<h3> <% rs.getString("heading"); %></h3>
<% } %>
All other statements like insert , delete are working.
Upvotes: 1
Views: 544
Reputation: 17461
Its a not a good practice to use that code in JSP layer . You should be using a backbean where you do your coding and just retrieve data to be viewed in JSP using JSTL.
Upvotes: 0
Reputation: 240928
It should be
<h3> <%= rs.getString("heading"); %></h3>
Note: putting java code in view is discouraged, put it in Servlet or Controller and use JSTL in view layer in jsp
Upvotes: 3