📄 user_0005freg_0002ejsp_jsp.java
字号:
import java.sql.*;
import java.util.*;
import java.text.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import org.apache.jasper.runtime.*;
public class user_0005freg_0002ejsp_jsp extends HttpJspBase {
static {
}
public user_0005freg_0002ejsp_jsp( ) {
}
private static boolean _jspx_inited = false;
public final void _jspx_init() throws org.apache.jasper.runtime.JspException {
}
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;
String _value = null;
try {
if (_jspx_inited == false) {
synchronized (this) {
if (_jspx_inited == false) {
_jspx_init();
_jspx_inited = true;
}
}
}
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html; charset=GBK");
pageContext = _jspxFactory.getPageContext(this, request, response,
"", true, 8192, true);
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
// HTML // begin [file="/user_reg.jsp";from=(0,48);to=(1,0)]
out.write("\r\n");
// end
// HTML // begin [file="/user_reg.jsp";from=(1,31);to=(2,0)]
out.write("\r\n");
// end
// HTML // begin [file="/user_reg.jsp";from=(2,31);to=(3,0)]
out.write("\r\n");
// end
// HTML // begin [file="/user_reg.jsp";from=(3,31);to=(14,0)]
out.write("\r\n<html>\r\n<head>\r\n<title>用户注册页面</title>\r\n<style type=\"text/css\">\r\n<!--\r\n.style1 {font-size: 36px}\r\n-->\r\n</style>\r\n</head>\r\n<body bgcolor=\"#ffffff\">\r\n");
// end
// begin [file="/user_reg.jsp";from=(14,0);to=(14,30)]
{
String _jspx_qStr = "";
JspRuntimeLibrary.include(request, response, "logo.jsp" + _jspx_qStr, out, false);
if ("true".equals(request.getAttribute("javax.servlet.forward.seen")))
return;
}
// end
// HTML // begin [file="/user_reg.jsp";from=(14,30);to=(49,0)]
out.write("\r\n<table width=\"80%\" height=\"147\" border=\"0\" align=\"center\">\r\n <form method=\"post\" action=\"\">\r\n <tr>\r\n <td width=\"244\" height=\"28\" align=\"center\">\r\n\t用户名:</td>\r\n <td width=\"537\" >\r\n <input name=\"username\" type=\"text\" size=\"15\" />\r\n <font color=\"#FF0000\">*</font>(以字母为准)</td>\r\n </tr>\r\n <tr>\r\n <td height=\"27\" align=\"center\">密 码:</td>\r\n <td height=\"27\">\r\n <input name=\"password1\" type=\"password\" size=\"15\" />\r\n <font color=\"#FF0000\">*</font>(至少6位)</td>\r\n </tr>\r\n <tr>\r\n <td height=\"28\" align=\"center\">确认密码:</td>\r\n <td height=\"28\">\r\n <input name=\"password2\" type=\"password\" size=\"15\" />\r\n <font color=\"#FF0000\">*</font>(至少6位)</td>\r\n </tr>\r\n <tr>\r\n <td height=\"29\" align=\"center\">E-mail:</td>\r\n <td height=\"29\"><input name=\"email\" type=\"text\" size=\"15\" />\r\n <font color=\"#FF0000\">*</font>(必须填写正确的E-mail)</td>\r\n </tr>\r\n <tr align=\"center\">\r\n <td colspan=\"2\">\r\n <input type=\"submit\" name=\"tijiao\" value=\"提交\" />\r\n <input type=\"reset\" name=\"reset1\" value=\"重填\" /> </td>\r\n </tr>\r\n </form>\r\n</table>\r\n\r\n");
// end
// begin [file="/user_reg.jsp";from=(49,2);to=(83,0)]
Connection conn=null;
ResultSet rs=null;
Statement stmt=null;
String date=new SimpleDateFormat("yyyy-MM-dd ").format(Calendar.getInstance().getTime());
String userip=request.getRemoteAddr();
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc:odbc:bbs","","");
stmt=conn.createStatement();
String username=request.getParameter("username");
String password1=request.getParameter("password1");
String password2=request.getParameter("password2");
String email=request.getParameter("email");
rs=stmt.executeQuery("select * from user where username='"+username+"'");
if(username.equals("")){
out.println("<script>alert('用户名不能为空!');</script>");}
else if(password1.equals("") || password2.equals("")){
out.println("<script>alert('密码不能为空!');</script>");}
else if(!password1.equals(password2)){
out.println("<script>alert('您输入的密码不一致,请重新输入!');</script>");}
else if(email.equals("")){
out.println("<script>alert('您输入的E-mail不正确,请重新输入!');</script>");}
else if(rs.next()){
out.println("<script>alert('该用户已被注册!');</script>");}
else{
session.setAttribute("username",username);
String loginvalue="INSERT INTO user(username,password,email,reg_time,reg_ip)VALUES"+"("+"'"+username+"','"+password1+"','"+email+"','"+date+"','"+userip+"'"+")";
stmt.execute(loginvalue);
out.println("<script>alert('恭喜您,注册成功!');this.location.href='index.jsp';</script>");
conn.close();}
}catch(Exception e){
out.println(e);
}
// end
// HTML // begin [file="/user_reg.jsp";from=(83,2);to=(86,0)]
out.write("\r\n</body>\r\n</html>\r\n");
// end
} catch (Throwable t) {
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (pageContext != null) pageContext.handlePageException(t);
} finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -