Q:view data from database
<%@page import="java.sql.Statement"%> <%@page import="java.sql.DriverManager"%> <%@page import="java.sql.Connection"%> <%@page import="java.sql.ResultSet"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <center> <h1>View Your Location</h1> <form action="view" method="POST"> <b> Enter Your Ignite Id:</b><input type="text" name="id" placeholder="IgniteId"><br><br> <input type="submit" value="SUBMIT" name="submit"><br><br><br> <table border="2"> <th>Name</th> <th>home</th> <th>Location</th> <% try { ResultSet rs = (ResultSet) request.getAttribute("data"); while (rs.next()) { %> <tr> <td><input type="text" value="<%=rs.getString("name")%>"</td> <td><input type="text" value="<%=rs.getString("home")%>"</td> <td><input type="text" value="<%=rs.getString("location")%>"</td> </tr> <% } } catch (Exception e) { } %> </table> </form> </center> </body> </html>
Ads