- 博客(0)
- 资源 (9)
- 收藏
- 关注
小型bbs jsp源代码
比较简单完整的jsp代码。如checklogin.jsp
<%@ page import="java.sql.*" contentType="text/html;charset=GB2312" %>
<HTML>
<BODY>
<jsp:useBean id="pool" scope="application" class="chapter10.ConnPool"/>
<%
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{%>
用户名或密码有误,请重新登录!
<%}%>
<a href="javascript:history.back();">返回</a>
</BODY>
</HTML>
2008-09-07
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人