-
大小: 255.93 KB文件类型: .rar金币: 1下载: 1 次发布日期: 2024-11-22
- 语言: Java
- 标签:
资源简介
实现JSP用户名 密码 验证码验证登陆
代码片段和文件信息
package cn.com.test;
import iit.jsp.DB.DBHelper;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
public class StudentLoginServlet extends HttpServlet {
private static final long serialVersionUID = -7672282350196270212L;
public void doGet(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
doPost(request response);
}
public void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
String input = request.getParameter(“rand“);
HttpSession session = request.getSession();
String rand = (String) session.getAttribute(“rand“);
if (rand.equals(input)) {
request.setCharacterEncoding(“UTF-8“);
String username = request.getParameter(“username“);
String password = request.getParameter(“password“);
String sql = “select suseridsusernamepasswordusercheck from student where susername=‘“
+ username + “‘ and password=‘“ + password + “‘“;
List list = null;
Student student = null;
QueryRunner qr = DBHelper.getQueryRunner();
try {
// 调用它的update方法,完成SQL的运行,update方法可用的操作:增、删、改
list = (List) qr.query(sql new BeanListHandler(Student.class));
} catch (SQLException e) {
e.printStackTrace();
}
if (list.size() > 0) {
student = (Student) list.get(0);
session.setAttribute(“student“ student);
if (student.getUsercheck().equals(“已审核“)) {
request.getRequestDispatcher(“/student/index.html“)
.forward(request response);
} else {
request.setAttribute(“message“ “账户正在审核,敬请等候审核通过!“);
request.getRequestDispatcher(“/student/loginresult.jsp“)
.forward(request response);
}
} else {
request.setAttribute(“message“ “用户名或者密码不正确!“);
request.getRequestDispatcher(“/student/loginresult.jsp“)
.forward(request response);
}
} else {
request.setAttribute(“message“ “验证码错误,请重新输入!“);
request.getRequestDispatcher(“/student/loginresult.jsp“).forward(
request response);
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 253 2008-06-04 18:48 images\!.gif
文件 1705 2008-06-04 18:48 images\ad.gif
文件 606 2008-06-04 18:48 images\add.gif
文件 213 2008-06-04 18:48 images\back.gif
文件 73 2008-06-04 18:48 images\bg.gif
文件 26509 2008-06-04 18:48 images\bigsize.jpg
文件 18679 2008-06-04 18:48 images\bootnbg.jpg
文件 179 2008-06-04 18:48 images\bullet.gif
文件 600 2008-06-04 18:48 images\buttom-copy-bg.gif
文件 1813 2008-06-04 18:48 images\buttom-left.gif
文件 2530 2008-06-04 18:48 images\buttom-right.gif
文件 225 2008-06-04 18:48 images\buttom_bgs.gif
文件 353 2008-06-04 18:48 images\buttom_left2.gif
文件 383 2008-06-04 18:48 images\buttom_right2.gif
文件 2001 2008-06-04 18:48 images\card.jpg
文件 350 2008-06-04 18:48 images\check-out_.gif
文件 502 2008-06-04 18:48 images\close.gif
文件 164 2008-06-04 18:48 images\content-bg-line.gif
文件 257 2008-06-04 18:48 images\content-bg.gif
文件 379 2008-06-04 18:48 images\databa
文件 1892 2008-06-04 18:48 images\DefaultDocs.gif
文件 1633 2008-06-04 18:48 images\defind.gif
文件 24832 2008-06-04 18:48 images\del.jpg
文件 618 2008-06-04 18:48 images\delete.gif
文件 617 2008-06-04 18:48 images\delete_6.gif
文件 624 2008-06-04 18:48 images\edit.gif
文件 2222 2008-06-04 18:48 images\ershou_1.gif
文件 2204 2008-06-04 18:48 images\ershou_2.gif
文件 610 2008-06-04 18:48 images\format.gif
文件 6986 2008-06-04 18:48 images\fox.css
............此处省略116个文件信息
评论
共有 条评论