⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index_jsp.java

📁 仿校内网站
💻 JAVA
字号:
package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import ArticleSharing.DBTools;
import java.sql.*;

public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();

  private static java.util.List _jspx_dependants;

  private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.AnnotationProcessor _jsp_annotationprocessor;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName());
  }

  public void _jspDestroy() {
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    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 {
      response.setContentType("text/html; charset=utf-8");
      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");
      out.write("\n");
      out.write("\n");
//定义错误信息            String errMessage = "";            String action = request.getParameter("action");            if (action != null) {                if (action.equals("submit")) {                    String user_name = request.getParameter("user_name");                    String password = request.getParameter("password");                    String sql = "select * from users where user_name = '" + user_name + "'";                    DBTools tool = new DBTools();                    ResultSet rs = tool.excuteQuery(sql);                    if (rs == null) {                        errMessage = "数据库异常";                    } else {                        if (rs.next()) {                            if (rs.getString("password").trim().equals(password.trim()) && rs.getString("user_name").trim().equals(user_name.trim())) {                                session.setAttribute("user_id", String.valueOf(rs.getInt("user_id")));                                session.setAttribute("user_name", user_name);                                session.setAttribute("image_id",String.valueOf(rs.getInt("user_id")));                                response.sendRedirect("frontpage.jsp");                            } else {                                errMessage = "密码错误";                            }                        } else {                            errMessage = "用户名不存在";                        }                    }                }            }
      out.write("\n");
      out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
      out.write("\n");
      out.write("<html>\n");
      out.write("    <head>\n");
      out.write("        <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
      out.write("        <!-- TemplateBeginEditable name=\"doctitle\" -->\n");
      out.write("        <title>会员登陆</title>\n");
      out.write("        <!-- TemplateEndEditable -->\n");
      out.write("<!-- TemplateBeginEditable name=\"head\" -->\n");
      out.write("        <!-- TemplateEndEditable -->\n");
      out.write("    </head>\n");
      out.write("    \n");
      out.write("    <body>\n");
      out.write("        <style type=\"text/css\">\n");
      out.write("            <!--\n");
      out.write("            .STYLE1 {\n");
      out.write("                color: #FF0000;\n");
      out.write("                font-weight: bold;\n");
      out.write("                font-size: large;\n");
      out.write("            }\n");
      out.write("            body {\n");
      out.write("                background-image: url(bdb9184ff956b920aec3abfe.jpg);\n");
      out.write("            }\n");
      out.write("            -->\n");
      out.write("        </style>\n");
      out.write("         <div style=\"margin-left:100px;\">\n");
      out.write("        <form id=\"form1\" name=\"form1\" method=\"post\" action=\"index.jsp?action=submit\">\n");
      out.write("            <div>\n");
      out.write("                <div><img src=\"photoes/1.gif\"></img></div>\n");
      out.write("                <div><img src=\"photoes/2.gif\"></img></div>\n");
      out.write("                <div style=\"float:left;\"><img src=\"photoes/3.gif\"></img></div>\n");
      out.write("                <div style=\"width:229px; height:73px;background-color:#FFFFFF\">\n");
      out.write("                    账号:<input name=\"user_name\" type=\"text\" id=\"user_name\" /><br>\n");
      out.write("                    密码:<input name=\"password\" type=\"password\" id=\"password\" />\n");
      out.write("                  <input type=\"submit\" value=\"登陆\" onclick=\"return validate();\" />\n");
      out.write("                    <input type=\"button\" name=\"register\" value=\"注册\" onclick=\"openWindow('register.jsp? type=register&ID=0');\" />\n");
      out.write("                </div>\n");
      out.write("                <div><img src=\"photoes/5.gif\"></img></div>\n");
      out.write("            </div>\n");
      out.write("           \n");
      out.write("         \n");
      out.write("            \n");
      out.write("        </form>\n");
      out.write("        </div>\n");
      out.write("        <hr>\n");
      out.write("        <div><font color=red>");
      out.print(errMessage);
      out.write("</font></div>\n");
      out.write("    </body>\n");
      out.write("    <script language=\"javascript\">\n");
      out.write("        function openWindow(url)\n");
      out.write("        {\n");
      out.write("            window.open(url,\"\",\"\");\n");
      out.write("        }    \n");
      out.write("    </script>\n");
      out.write("    <script language=\"javascript\">\n");
      out.write("        var code ; //在全局 定义验证码\n");
      out.write("      function createCode()\n");
      out.write("        { \n");
      out.write("            code = \"\";\n");
      out.write("            var codeLength = 6;//验证码的长度\n");
      out.write("            var checkCode = document.getElementById(\"checkCode\");\n");
      out.write("            var selectChar = new Array(0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');//所有候选组成验证码的字符,当然也可以用中文的\n");
      out.write("\n");
      out.write("            for(var i=0;i<codeLength;i++)\n");
      out.write("            {\n");
      out.write("\n");
      out.write("\n");
      out.write("                var charIndex = Math.floor(Math.random()*36);\n");
      out.write("                code +=selectChar[charIndex];\n");
      out.write("\n");
      out.write("\n");
      out.write("            }\n");
      out.write("            // alert(code);\n");
      out.write("            if(checkCode)\n");
      out.write("            {\n");
      out.write("                checkCode.className=\"code\";\n");
      out.write("                checkCode.value = code;\n");
      out.write("            }\n");
      out.write("\n");
      out.write("        }\n");
      out.write("        function validate()\n");
      out.write("        {\n");
      out.write("            \n");
      out.write("            var f = document.form1;\n");
      out.write("            if(f.user_name.value == \"\")\n");
      out.write("            {\n");
      out.write("                alert(\"用户名不能为空\");\n");
      out.write("                return false;\n");
      out.write("            }\n");
      out.write("            \n");
      out.write("            if(f.password.value == \"\")\n");
      out.write("            {\n");
      out.write("                alert(\"密码不能为空\");\n");
      out.write("                return false;\n");
      out.write("            }\n");
      out.write("      \n");
      out.write("     \n");
      out.write("            return true;\n");
      out.write("            \n");
      out.write("        }\n");
      out.write("    </script>\n");
      out.write("</html>\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}

⌨️ 快捷键说明

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