login.jsp

来自「JSP+ORACLE网站开发实例(下).rar」· JSP 代码 · 共 66 行

JSP
66
字号
<%@ include file="conn.jsp"%>
<%request.setCharacterEncoding("GB2312");
String user_name=request.getParameter("user_name");
password=request.getParameter("password");

if((password==null)|(user_name==null)){
   out.print("<script language='javascript'>");
   out.print("alert('数据填写有错!');");
   out.print("history.go(-1);");
   out.print("</script>");
}

%>

<%
String sql="select * from scott.user_reg where user_name like '"+user_name+"' and password like '"+ password+"'"; 
ResultSet rs_user=stmt.executeQuery(sql); 
   if(!rs_user.next()){

%>
<html>

<head>
<style>
<!--
a:link       { color: blue; text-decoration: none }
a:visited    { color: blue; text-decoration: none }
a:active     { color: #ff9966; text-decoration: none }
a:hover      { color: red; text-decoration: none }
-->
</style>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>提示信息</title>
</head>

<body>

<div align="center">
  <center>
    <table border="1" width="400" bordercolor="#CC0000" cellspacing="0" cellpadding="0" height="120" bgcolor="#B89D77">
      <tr>
        <td width="100%" height="16"> 
          <p align="center"><b><font color="#FFFFFF" size="3">错误提示</font></b>
        </td>
    </tr>
      <tr> 
        <td width="100%" bgcolor="#DDF9FF" height="100"> 
          <p align="center"><font size="3">用户名或密码错误!</font></p>
        <p align="center"><font size="2"><a href="default.jsp">[返回]</a></font></td>
    </tr>
  </table>
  </center>
</div>

</body>

</html>
<%}else{
	session.putValue("user_id", rs_user.getString("user_id")); 
        rs_user.close();
	response.sendRedirect("your.jsp"); 

}%>        

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?