Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%--
- Document : newjsp
- Created on : Apr 15, 2017, 1:14:17 PM
- Author : Spyweeb
- --%>
- <%@page import="java.sql.DriverManager"%>
- <%@page import="java.sql.ResultSet"%>
- <%@page import="java.sql.Statement"%>
- <%@page import="java.sql.Connection"%>
- <%@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>
- <style>
- th,tr,td
- {
- font-family: Lucida Sans;
- }
- th{
- background-color: aquamarine;
- }
- </style>
- </head>
- <%!
- Connection conn;
- Statement stmt;
- ResultSet rs;
- public Connection getCon(){
- try{
- Class.forName("oracle.jdbc.OracleDriver");
- conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "hr", "ntic");
- }catch(Exception e){
- e.printStackTrace();
- }
- return conn;
- }
- %>
- <%
- try{
- stmt = getCon().createStatement();
- rs = stmt.executeQuery("SELECT first_name, job_id FROM employees");
- %>
- <body>
- <div align="center">
- <table border="1" cellpadding="9" style="border-collapse: collapse">
- <tbody>
- <tr>
- <th></th>
- <th>First Name</th>
- <th>Job</th>
- </tr>
- <% while(rs.next()){%>
- <tr>
- <td><input type="checkbox" name="" value="ON" /></td>
- <td> <%= rs.getString("first_name") %> </td>
- <td> <%= rs.getString("job_id") %> </td>
- </tr>
- <% } %>
- </tbody>
- </table>
- <%
- }catch(Exception ex){
- ex.printStackTrace();
- }
- %>
- </div>
- </body>
- </html>
Add Comment
Please, Sign In to add comment