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

📄 add_jsp.java

📁 一个简单的客户关系管理的JSP程序
💻 JAVA
字号:
package org.apache.jsp;

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

public final class add_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,
      			"", true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n<html>\r\n<head>\r\n<title>add</title>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\r\n\r\n<script language=\"javascript\" type=\"\">\r\nfunction isok(theform)\r\n{\r\nvar str=theform.custidfield.value;\r\nif(str==null ||str.length==0)\r\n {\r\n alert(\"用户ID不能为空!\");\r\n theform.custidfield.focus();\r\n return (false);\r\n }\r\n if(str.length<3 ||str.length>8)\r\n {\r\n alert(\"用户ID最少要3位,最多8位!\");\r\n theform.custidfield.focus();\r\n return (false);\r\n }\r\n\r\n var str1=theform.custnamefield.value;\r\n if(str1==null ||str1.length==0)\r\n {\r\n alert(\"用户名不能为空!\");\r\n theform.custnamefield.focus();\r\n return (false);\r\n }\r\n var pattern=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+.([a-zA-Z0-9_-])/;\r\n if(!pattern.exec(theform.emailfield.value))\r\n {\r\n alert(\"请重新输入邮件地址!\");\r\n theform.emailfield.focus();\r\n return (false);\r\n }\r\n return (true);\r\n}\r\n\r\n</script>\r\n\r\n</head>\r\n\r\n<body>\r\n<h2>增加客户</h2>\r\n<form name=\"form1\" method=\"post\" action=\"\" onsubmit=\"return isok(this)\">\r\n  <p>客户ID:\r\n    <input name=\"custidfield\" type=\"text\" id=\"custidfield\">\r\n  </p>\r\n  <p>姓&nbsp;&nbsp;名:\r\n");
      out.write("    <input name=\"custnamefield\" type=\"text\" id=\"custnamefield\">\r\n  </p>\r\n  <p>年&nbsp;&nbsp;龄:\r\n    <input name=\"agefield\" type=\"text\" id=\"agefield\">\r\n  </p>\r\n  <p>电&nbsp;&nbsp;话:\r\n    <input name=\"telfield\" type=\"text\" id=\"telfield\">\r\n  </p>\r\n  <p>Email:&nbsp;\r\n    <input name=\"emailfield\" type=\"text\" id=\"emailfield\">\r\n  </p>\r\n  <p>公&nbsp;&nbsp;司:\r\n    <input name=\"comfield\" type=\"text\" id=\"comfield\">\r\n  </p>\r\n  <p>\r\n    <input type=\"submit\" name=\"Submit\" value=\"提交\">\r\n    <input type=\"reset\" name=\"Submit2\" value=\"清除\">\r\n  </p>\r\n</form>\r\n<p>&nbsp;</p>\r\n");
      crm.SQLDAO dao = null;
      synchronized (session) {
        dao = (crm.SQLDAO) _jspx_page_context.getAttribute("dao", PageContext.SESSION_SCOPE);
        if (dao == null){
          dao = new crm.SQLDAO();
          _jspx_page_context.setAttribute("dao", dao, PageContext.SESSION_SCOPE);
        }
      }
      out.write('\r');
      out.write('\n');

if(request.getParameter("Submit")!=null){
//request.setCharacterEncoding("GB2312");
String custid=new String(request.getParameter("custidfield").getBytes("8859_1"));
String custname=new String(request.getParameter("custnamefield").getBytes("8859_1"));
int age=Integer.parseInt(new String(request.getParameter("agefield").getBytes("8859_1")));
String tel=new String(request.getParameter("telfield").getBytes("8859_1"));
String email=new String(request.getParameter("emailfield").getBytes("8859_1"));
String com=new String(request.getParameter("comfield").getBytes("8859_1"));
if(dao.insert(custid,custname,age,tel,email,com)){
out.print("<h2>增加客户成功!</h2>");
}
}

      out.write("\r\n</body>\r\n</html>\r\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 + -