JSP学生火车票订票系统 第4页
try {
stmt = conn.createStatement();
rs=stmt.executeQuery(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return rs;
}
public void newerin(String sql){
Statement stmt;
try {
stmt = conn.createStatement();
stmt.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();(2)、登录模块:
登录界面对应的是index.jsp页面。在该页面,学生和管理员都可以在此登录,单选框可以起到判断登录人是否是管理员的作用。登录后用户将按其是学生或管理员分别进入各自主界面。
登录身份检测主要代码实现如下:
package beans;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;
public class Comfirm extends HttpServlet {
private static final long serialVersionUID = -3983093134005309850L;
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
response.setCharacterEncoding("GB2312");
PrintWriter out = response.getWriter();
request.setCharacterEncoding("GB2312");
String right,username,password;
right=request.getParameter("right");
username=request.getParameter("username");
password=request.getParameter("password");
OperateDb check=new OperateDb();
String sql;
sql="select sname,scode from "+right;
ResultSet rs=check.query(sql);
try {
while(rs.next()){
String name,pass;
name=rs.getString(1);
pass=rs.getString(2);
if(name.equals(username)&&pass.equals(password))
{
String pageName;
pageName="//"+right+".jsp";
gotoPage(pageName,request,response);
return;
//RequestDispatcher d=getServletContext().getRequestDispatcher(pageName);
//d.forward(request, response);
}
}
gotoPage("/error.jsp",request,response);
return;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
out.flush();
out.close(); }
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
}
public void gotoPage(String pageName,HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException{
RequestDispatcher d=getServletContext().getRequestDispatcher(pageName);
d.forward(request, response);
}
}
(3)、管理员模块:
1、管理员主界面:此页面对应admin.jsp页面。在此页面左下方菜单栏的账号管理对应上面的管理员系统设置模块图;管理操作中包括上面的车票信息管理模块图及订票管理模块图。
上一页 [1] [2] [3] [4] [5] [6] 下一页