select_for_age.jsp

 

<%@ page language=”java” import=”java.util.*” pageEncoding=”UTF-8″%>

<%@ page import=”java.sql.*”%>

The < %

String path = request.getContextPath();

String basePath = request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”;

% >

 

<! DOCTYPE HTML PUBLIC “-//W3C// HTML 4.01 Transitional//EN”>

<html>

  <head>

    <base href=”<%=basePath%>”>

    

<title> Query by age </title>

    

<meta http-equiv=”pragma” content=”no-cache”>

<meta http-equiv=”cache-control” content=”no-cache”>

<meta http-equiv=”expires” content=”0″>    

<meta http-equiv=”keywords” content=”keyword1,keyword2,keyword3″>

<meta http-equiv=”description” content=”This is my page”>

<! —

<link rel=”stylesheet” type=”text/css” href=”styles.css”>

–>

 

  </head>

  

  <body background=”pic/background.jpg”>

The < %

    request.setCharacterEncoding(“UTF-8”);

    String age = request.getParameter(“age”);

    Connection conn = null;

    Statement stat = null;

    ResultSet rs = null;

    Class.forName(“com.mysql.jdbc.Driver”);

    String url = “jdbc:mysql://localhost:3306/jsp”;

    String user = “root”;

    String password = “root”;

    conn = DriverManager.getConnection(url,user,password);

    stat = conn.createStatement();

    rs = stat.executeQuery(“select * from student where age=” + age + “”);

% >

    <br>

< H3 > Information about eligible students </ H3 >< HR >

    <br>

<table width=”450″ border=”100″ cellSpacing=1 style=”font-size:15pt; border:dashed 1pt”>

    <tr>

< td > student id < / td >

Name of the < td > < / td >

Age < td > < / td >

Gender < td > < / td >

< td > < / td >

    </tr>

The < %

    while(rs.next())

    {

    out.print(“<tr>”);

    out.print(“<td>” + rs.getInt(“id”) + “</td>”);

    out.print(“<td>” + rs.getString(“name”) + “</td>”);

    out.print(“<td>” + rs.getInt(“age”) + “</td>”);

    out.print(“<td>” + rs.getString(“gender”) + “</td>”);

    out.print(“<td>” + rs.getString(“major”) + “</td>”);

% >

<td><a href=”delete.jsp? Id =<%= rs.getint (“id”) %> delete </a></td>

<td><a href=”update.jsp? Id =<%= rs.getint (“id”) %>” </a></ TD >

The < %

    out.print(“</tr>”);

    }

  

  

% >

      </table>

      <br>

      <br>

<h4><a href= showinfo.jsp >

The < %

if(rs ! = null)

    {

        rs.close();

        rs = null;

    }

if(stat ! = null)

    {

        stat.close();

        stat = null;

    }

if(conn ! = null)

    {

        conn.close();

        conn = null;

    }

% >

  </body>

</html>

 

 

 

 

 

select_for_gender

 

<%@ page language=”java” import=”java.util.*” pageEncoding=”UTF-8″%>

<%@ page import=”java.sql.*”%>

The < %

String path = request.getContextPath();

String basePath = request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”;

% >

 

<! DOCTYPE HTML PUBLIC “-//W3C// HTML 4.01 Transitional//EN”>

<html>

  <head>

    <base href=”<%=basePath%>”>

    

<title> Query by gender </title>

    

<meta http-equiv=”pragma” content=”no-cache”>

<meta http-equiv=”cache-control” content=”no-cache”>

<meta http-equiv=”expires” content=”0″>    

<meta http-equiv=”keywords” content=”keyword1,keyword2,keyword3″>

<meta http-equiv=”description” content=”This is my page”>

<! —

<link rel=”stylesheet” type=”text/css” href=”styles.css”>

–>

 

  </head>

  

  <body background=”pic/background.jpg”>

The < %

    request.setCharacterEncoding(“UTF-8”);

    String gender = request.getParameter(“gender”);

    Connection conn = null;

    Statement stat = null;

    ResultSet rs = null;

    Class.forName(“com.mysql.jdbc.Driver”);

    String url = “jdbc:mysql://localhost:3306/jsp”;

    String user = “root”;

    String password = “root”;

    conn = DriverManager.getConnection(url,user,password);

    stat = conn.createStatement();

    rs = stat.executeQuery(“select * from student where gender='” + gender + “‘”);

% >

    <br>

< H3 > Information about eligible students </ H3 >< HR >

    <br>

<table width=”450″ border=”100″ cellSpacing=1 style=”font-size:15pt; border:dashed 1pt”>

    <tr>

< td > student id < / td >

Name of the < td > < / td >

Age < td > < / td >

Gender < td > < / td >

< td > < / td >

    </tr>

The < %

    while(rs.next())

    {

    out.print(“<tr>”);

    out.print(“<td>” + rs.getInt(“id”) + “</td>”);

    out.print(“<td>” + rs.getString(“name”) + “</td>”);

    out.print(“<td>” + rs.getInt(“age”) + “</td>”);

    out.print(“<td>” + rs.getString(“gender”) + “</td>”);

    out.print(“<td>” + rs.getString(“major”) + “</td>”);

% >

<td><a href=”delete.jsp? Id =<%= rs.getint (“id”) %> delete </a></td>

<td><a href=”update.jsp? Id =<%= rs.getint (“id”) %>” </a></ TD >

The < %

    out.print(“</tr>”);

    }

% >

      </table>

      <br>

      <br>

<h4><a href= showinfo.jsp >

The < %

if(rs ! = null)

    {

        rs.close();

        rs = null;

    }

if(stat ! = null)

    {

        stat.close();

        stat = null;

    }

if(conn ! = null)

    {

        conn.close();

        conn = null;

    }

% >

  </body>

</html>

 

 

select_for_id.jsp

 

 

<%@ page language=”java” import=”java.util.*” pageEncoding=”UTF-8″%>

<%@ page import=”java.sql.*”%>

The < %

String path = request.getContextPath();

String basePath = request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”;

% >

<! DOCTYPE HTML PUBLIC “-//W3C// HTML 4.01 Transitional//EN”>

<html>

  <head>

    <base href=”<%=basePath%>”>

    

    <title>按学号条件查询</title>

    

<meta http-equiv=”pragma” content=”no-cache”>

<meta http-equiv=”cache-control” content=”no-cache”>

<meta http-equiv=”expires” content=”0″>    

<meta http-equiv=”keywords” content=”keyword1,keyword2,keyword3″>

<meta http-equiv=”description” content=”This is my page”>

<! —

<link rel=”stylesheet” type=”text/css” href=”styles.css”>

–>

  </head>

  

  <body background=”pic/background.jpg”>

The < %

    request.setCharacterEncoding(“UTF-8”);

    String id = request.getParameter(“id”);

    Connection conn = null;

    Statement stat = null;

    ResultSet rs = null;

    Class.forName(“com.mysql.jdbc.Driver”);

    String url = “jdbc:mysql://localhost:3306/jsp”;

    String user = “root”;

    String password = “root”;

    conn = DriverManager.getConnection(url,user,password);

    stat = conn.createStatement();

    rs = stat.executeQuery(“select * from student where id=” + id + “”);

% >

    <br>

< H3 > Information about eligible students </ H3 >< HR >

    <br>

<table width=”450″ border=”100″ cellSpacing=1 style=”font-size:15pt; border:dashed 1pt”>

    <tr>

< td > student id < / td >

Name of the < td > < / td >

Age < td > < / td >

Gender < td > < / td >

< td > < / td >

    </tr>

The < %

    if(rs.next())

    {

    out.print(“<tr>”);

    out.print(“<td>” + rs.getInt(“id”) + “</td>”);

    out.print(“<td>” + rs.getString(“name”) + “</td>”);

    out.print(“<td>” + rs.getInt(“age”) + “</td>”);

    out.print(“<td>” + rs.getString(“gender”) + “</td>”);

    out.print(“<td>” + rs.getString(“major”) + “</td>”);

% >

<td><a href=”delete.jsp? Id =<%= rs.getint (“id”) %> delete </a></td>

<td><a href=”update.jsp? Id =<%= rs.getint (“id”) %>” </a></ TD >

The < %

    out.print(“</tr>”);

    }

    else{

Print (“<h4> <h4> </h4>”);

    }

  

% >

      </table>

      <br>

      <br>

<h4><a href= showinfo.jsp >

The < %

if(rs ! = null)

    {

        rs.close();

        rs = null;

    }

if(stat ! = null)

    {

        stat.close();

        stat = null;

    }

if(conn ! = null)

    {

        conn.close();

        conn = null;

    }

% >

    

  </body>

</html>

 

 

select_for_major.jsp

 

<%@ page language=”java” import=”java.util.*” pageEncoding=”UTF-8″%>

<%@ page import=”java.sql.*”%>

The < %

String path = request.getContextPath();

String basePath = request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”;

% >

 

<! DOCTYPE HTML PUBLIC “-//W3C// HTML 4.01 Transitional//EN”>

<html>

  <head>

    <base href=”<%=basePath%>”>

    

<title> Query by profession </title>

    

<meta http-equiv=”pragma” content=”no-cache”>

<meta http-equiv=”cache-control” content=”no-cache”>

<meta http-equiv=”expires” content=”0″>    

<meta http-equiv=”keywords” content=”keyword1,keyword2,keyword3″>

<meta http-equiv=”description” content=”This is my page”>

<! —

<link rel=”stylesheet” type=”text/css” href=”styles.css”>

–>

 

  </head>

  

  <body background=”pic/background.jpg”>

The < %

    request.setCharacterEncoding(“UTF-8”);

   // String id=request.getParameter(“id”);

  // String name=request.getParameter(“name”);

   // String age=request.getParameter(“age”);

   // String gender=request.getParameter(“gender”);

    String major=request.getParameter(“major”);

    //major=;

    

    

    Connection conn = null;

    Statement stat = null;

    ResultSet rs = null;

    Class.forName(“com.mysql.jdbc.Driver”);

    String url = “jdbc:mysql://localhost:3306/jsp”;

    String user = “root”;

    String password = “root”;  

    conn = DriverManager.getConnection(url,user,password);

    stat = conn.createStatement();

    rs = stat.executeQuery(“select * from student where major='” + major + “‘”);

% >

    <br>

< H3 > Information about eligible students </ H3 >< HR >

    <br>

<table width=”450″ border=”100″ cellSpacing=1 style=”font-size:15pt; border:dashed 1pt”>

    <tr>

< td > student id < / td >

Name of the < td > < / td >

Age < td > < / td >

Gender < td > < / td >

< td > < / td >

    </tr>

The < %

    while(rs.next())

    {

    out.print(“<tr>”);

    out.print(“<td>” + rs.getInt(“id”) + “</td>”);

    out.print(“<td>” + rs.getString(“name”) + “</td>”);

    out.print(“<td>” + rs.getInt(“age”) + “</td>”);

    out.print(“<td>” + rs.getString(“gender”) + “</td>”);

    out.print(“<td>” + rs.getString(“major”) + “</td>”);

% >

<td> <a href=”delete.jsp? Id =<%= rs.getint (“id”) %> delete </a></td>

<td><a href=”update.jsp? Id =<%= rs.getint (“id”) %>” </a></ TD >

The < %

    out.print(“</tr>”);

    }

    

% >

      </table>

      <br>

      <br>

<h4><a href= showinfo.jsp >

The < %

if(rs ! = null)

    {

        rs.close();

        rs = null;

    }

if(stat ! = null)

    {

        stat.close();

        stat = null;

    }

if(conn ! = null)

    {

        conn.close();

        conn = null;

    }

% >

  </body>

</html>

 

 

select_for_name.jsp

 

 

<%@ page language=”java” import=”java.util.*” pageEncoding=”UTF-8″%>

<%@ page import=”java.sql.*”%>

The < %

String path = request.getContextPath();

String basePath = request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”;

% >

 

<! DOCTYPE HTML PUBLIC “-//W3C// HTML 4.01 Transitional//EN”>

<html>

  <head>

    <base href=”<%=basePath%>”>

    

<title> Query by name </title>

    

<meta http-equiv=”pragma” content=”no-cache”>

<meta http-equiv=”cache-control” content=”no-cache”>

<meta http-equiv=”expires” content=”0″>    

<meta http-equiv=”keywords” content=”keyword1,keyword2,keyword3″>

<meta http-equiv=”description” content=”This is my page”>

<! —

<link rel=”stylesheet” type=”text/css” href=”styles.css”>

–>

  </head>

  

  <body background=”pic/background.jpg”>

The < %

    request.setCharacterEncoding(“UTF-8”);

    String name = request.getParameter(“name”);

    Connection conn = null;

    Statement stat = null;

    ResultSet rs = null;

    Class.forName(“com.mysql.jdbc.Driver”);

    String url=”jdbc:mysql://localhost:3306/jsp”;

    String user = “root”;

    String password = “root”;

    conn = DriverManager.getConnection(url,user,password);

    stat = conn.createStatement();

    rs = stat.executeQuery(“select * from student where name='” + name + “‘”);

% >

    <br>

< H3 > Information about eligible students </ H3 >< HR >

    <br>

<table width=”450″ border=”100″ cellSpacing=1 style=”font-size:15pt; border:dashed 1pt”>

    <tr>

< td > student id < / td >

Name of the < td > < / td >

Age < td > < / td >

Gender < td > < / td >

< td > < / td >

    </tr>

The < %

    while(rs.next())

    {

    out.print(“<tr>”);

    out.print(“<td>” + rs.getInt(“id”) + “</td>”);

    out.print(“<td>” + rs.getString(“name”) + “</td>”);

    out.print(“<td>” + rs.getInt(“age”) + “</td>”);

    out.print(“<td>” + rs.getString(“gender”) + “</td>”);

    out.print(“<td>” + rs.getString(“major”) + “</td>”);

% >

<td><a href=”delete.jsp? Id =<%= rs.getint (“id”) %> delete </a></td>

<td><a href=”update.jsp? Id =<%= rs.getint (“id”) %>” </a></ TD >

The < %

    out.print(“</tr>”);

    }

   

% >

      </table>

      <br>

      <br>

<h4><a href= showinfo.jsp >

The < %

if(rs ! = null)

    {

        rs.close();

        rs = null;

    }

if(stat ! = null)

    {

        stat.close();

        stat = null;

    }

if(conn ! = null)

    {

        conn.close();

        conn = null;

    }

% >

  </body>

</html>

 

 

 

 

showInfo.jsp

 

 

<%@ page language=”java” import=”java.util.*” pageEncoding=”UTF-8″%>

<%@ page import=”java.sql.*”%>

The < %

String path = request.getContextPath();

String basePath = request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”;

% >

 

<! DOCTYPE HTML PUBLIC “-//W3C// HTML 4.01 Transitional//EN”>

<html>

  <head>

    <base href=”<%=basePath%>”>

    

<title> Student information </title>

    

<meta http-equiv=”pragma” content=”no-cache”>

<meta http-equiv=”cache-control” content=”no-cache”>

<meta http-equiv=”expires” content=”0″>    

<meta http-equiv=”keywords” content=”keyword1,keyword2,keyword3″>

<meta http-equiv=”description” content=”This is my page”>

<! —

<link rel=”stylesheet” type=”text/css” href=”styles.css”>

–>

 

  </head>

  

  <body background=”pic/background.jpg”>

The < %

    response.setCharacterEncoding(“UTF-8”);

    request.setCharacterEncoding(“UTF-8”);

    String id = request.getParameter(“id”);

    String name = request.getParameter(“name”);

    String age = request.getParameter(“age”);

    String gender = request.getParameter(“gender”);

    String major = request.getParameter(“major”);

    Connection conn = null;

    Statement stat = null;

    ResultSet rs = null;

    Class.forName(“com.mysql.jdbc.Driver”);

    String url = “jdbc:mysql://localhost:3306/jsp”;

    String user = “root”;

    String password = “root”;

    conn = DriverManager.getConnection(url,user,password);

    stat = conn.createStatement();

    rs = stat.executeQuery(“select * from student”);

% >

  <br>

<h2> Student information </h2> < HR >

    <br>

< H3 > All student information is as follows </ H3 >

<table width=”450″ border=”100″ cellSpacing=3 style=”font-size:15pt; border:dashed 1pt”>

    <tr>

< td > student id < / td >

Name of the < td > < / td >

Age < td > < / td >

Gender < td > < / td >

< td > < / td >

    </tr>

The < %

    while(rs.next())

    {

    out.print(“<tr>”);

    out.print(“<td>” + rs.getInt(“id”) + “</td>”);

    out.print(“<td>” + rs.getString(“name”) + “</td>”);

    out.print(“<td>” + rs.getInt(“age”) + “</td>”);

    out.print(“<td>” + rs.getString(“gender”) + “</td>”);

    out.print(“<td>” + rs.getString(“major”) + “</td>”);

% >

<td><a href=”delete.jsp? Id =<%= rs.getint (“id”) %> delete </a></td>

<td><a href=”update.jsp? Id =<%= rs.getint (“id”) %>” </a></ TD >

The < %

    out.print(“</tr>”);

    }

  

% >

      </table>

      

      <br>

    <form action=”select_for_id.jsp” method=”post”>

   

<h3> Query by student number :<input type=”text” name=”id” value=”” title=” student number cannot be empty “></input>

< form type=”submit” value=” query “/></h3>

    <br>

    </form>

    

    <form action=”select_for_name.jsp” method=”post”>

<input type=”text” name=”name” value=”” title=” name cannot be empty “></input>

< form type=”submit” value=” query “/></h3>

    <br>

    </form>

    

    <form action=”select_for_age.jsp” method=”post”>

<input type=”text” name=”age” value=”” title=” age cannot be empty “></input>

< form type=”submit” value=” query “/></h3>

    <br>

    </form>

    

    <form action=”select_for_gender.jsp” method=”post”>

<h3> Query by gender :<input type=”text” name=”gender” value=”” title=” gender cannot be empty “></input>

< form type=”submit” value=” query “/></h3>

    <br>

    </form>

    

    <form action=”select_for_major.jsp” method=”post”>

<input type=”text” name=”major” value=”” title=” “></input>

< form type=”submit” value=” query “/></h3>

    <br>

    </form>

<br>

<h3><a href= addstuinfo.jsp > Return to add student information page </a></h3>

<br>

 

The < %

if(rs ! = null)

    {

        rs.close();

        rs = null;

    }

if(stat ! = null)

    {

        stat.close();

        stat = null;

    }

if(conn ! = null)

    {

        conn.close();

        conn = null;

    }

% >

   

  </body>

</html>

Building Lord QQ: 496056171