📄 login_jsp.java
字号:
package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
public final class login_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {
private static java.util.Vector _jspx_dependants;
public java.util.List getDependants() {
return _jspx_dependants;
}
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {
JspFactory _jspxFactory = null;
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;
try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html; charset=gb2312");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write('\n');
out.write('\n');
check.login alogin = null;
synchronized (_jspx_page_context) {
alogin = (check.login) _jspx_page_context.getAttribute("alogin", PageContext.PAGE_SCOPE);
if (alogin == null){
alogin = new check.login();
_jspx_page_context.setAttribute("alogin", alogin, PageContext.PAGE_SCOPE);
}
}
out.write('\n');
try{String mesg = "";if( request.getParameter("username")!=null && !request.getParameter("username").equals("")){ String username =request.getParameter("username"); String passwd = request.getParameter("passwd"); username = new String(username.getBytes("ISO8859-1")); passwd = new String(passwd.getBytes("ISO8859-1")); alogin.setUsername(username); alogin.setPasswd(passwd); if (alogin.excute()){ session.setAttribute("username",username); String userid = Long.toString(alogin.getUserid()); session.setAttribute("userid",userid); response.sendRedirect("user.jsp");
out.write('\n');
}else { mesg = "登录出错!" ; }}
out.write("\n");
out.write("\n");
out.write("<html>\n");
out.write("<head>\n");
out.write("<title>>使用seesion对象进行身份验证</title>\n");
out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\n");
out.write("<script type=\"\" language=\"javascript\">\n");
out.write("\n");
out.write(" function checkform() {\n");
out.write("\tif (document.form1.username.value==\"\" || document.form1.passwd.value==\"\"){\n");
out.write("\t\talert(\"用户名或密码为不能为空!\");\n");
out.write("\t\treturn false;\n");
out.write("\t}\n");
out.write("\treturn true;\n");
out.write("\n");
out.write(" }\n");
out.write("\n");
out.write("</script>\n");
out.write("<link rel=\"stylesheet\" href=\"books.css\" type=\"text/css\">\n");
out.write("<style type=\"text/css\">\n");
out.write("<!--\n");
out.write("body {\n");
out.write("\n");
out.write("\tbackground-image: url(../../mypicture/bg06.jpg);\n");
out.write("}\n");
out.write(".style2 {\n");
out.write("\tcolor: #669900;\n");
out.write("\tfont-size: 16px;\n");
out.write("}\n");
out.write(".style4 {color: #CC6666}\n");
out.write(".style5 {color: #669900}\n");
out.write("-->\n");
out.write("</style>\n");
out.write("</head>\n");
out.write("\n");
out.write("<body text=\"#000000\">\n");
out.write("<div align=\"center\">\n");
out.write(" <p class=\"style2\">用户登录</p>\n");
out.write(" ");
if (!mesg.equals("")){ out.println("<p>" + mesg + "</p>");} }catch(Exception e){e.printStackTrace();}
out.write("\n");
out.write(" <form name=\"form1\" method=\"post\" action=\"login.jsp\">\n");
out.write(" <table width=\"400\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\">\n");
out.write(" <tr>\n");
out.write(" <td width=\"147\" align=\"right\"><span class=\"style5\">用户名:</span><br> </td>\n");
out.write(" <td width=\"246\" valign=\"top\">\n");
out.write(" <input type=\"text\" name=\"username\" size=\"16\" maxlength=\"25\">\n");
out.write(" </td>\n");
out.write(" </tr>\n");
out.write(" <tr>\n");
out.write(" <td width=\"147\" align=\"right\"><span class=\"style5\">密 码:</span></td>\n");
out.write(" <td width=\"246\" valign=\"top\">\n");
out.write(" <input type=\"password\" name=\"passwd\" maxlength=\"20\" size=\"16\">\n");
out.write(" </td>\n");
out.write(" </tr>\n");
out.write(" <tr>\n");
out.write(" <td width=\"147\" align=\"right\"> </td>\n");
out.write(" <td width=\"246\" valign=\"top\">\n");
out.write(" <input type=\"submit\" name=\"Submit\" value=\"登录\" onclick=\"javascript:return(checkform());\">\n");
out.write(" <input type=\"reset\" name=\"Submit2\" value=\"取消\">\n");
out.write(" </td>\n");
out.write(" </tr>\n");
out.write(" <tr>\n");
out.write(" <td colspan=\"2\" align=\"center\">\n");
out.write(" <p> </p>\n");
out.write(" <p><span class=\"style4\">如果你还没有注册,请</span><a href=\"reg.jsp\">注册</a></p>\n");
out.write(" </td>\n");
out.write(" </tr>\n");
out.write(" </table>\n");
out.write(" </form>\n");
out.write(" <p> </p>\n");
out.write("</div>\n");
out.write("</body>\n");
out.write("</html>\n");
} catch (Throwable t) {
if (!(t instanceof SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
}
} finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -