资源介绍
比较简单完整的jsp代码。如checklogin.jsp
<%@ page import="java.sql.*" contentType="text/html;charset=GB2312" %>
<%
boolean success=true;
boolean disable=false;
String name=new String(request.getParameter("name").getBytes("ISO8859_1"),"GBK"); //将中文字符转换成标准字符的写法
String password=new String(request.getParameter("password").getBytes("ISO8859_1"),"GBK");%>
<%@ include file="conn.jsp"%>
<%
sql="select * from users where name='"+name+"' and password='"+password+"'";
ResultSet rs =statement.executeQuery(sql);
if (rs.next())
{
disable=rs.getBoolean("Disable");
if (disable)
{success=false;}
} else{
success=false;
}
%>
<%@include file="disconn.jsp"%>
<%
if (success){
session.setAttribute("Name",name); // 思考:为什么用session 存放此变量,还有什么变量能存在session中
response.sendRedirect("list.jsp"); // 页面跳转 ,试试用另一种方式表现
}else if (disable){%>
该用户已经被禁用!
<%}else{%>
用户名或密码有误,请重新登录!
<%}%>
返回
- 上一篇: Inletex easy meeting classic
- 下一篇: BBS论坛源代码JSP