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

📄 index_jsp.java

📁 java写的servlet服务器端
💻 JAVA
字号:
package org.apache.jsp;

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

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

  private static java.util.List _jspx_dependants;

  public Object 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");
      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("<html>\r\n");
      out.write("<HEAD><TITLE>HoroscopeServlet</TITLE>\r\n");
      out.write("<SCRIPT LANGUAGE = \"JavaScript\">\t\r\n");
      out.write("\t\r\n");
      out.write("\tfunction testName(){\r\n");
      out.write("\t\tvar reName = /^[A-Z][a-z]+\\s([\\.-]?([A-Z][a-z]+))$/  // regular expressioin for name\r\n");
      out.write("\t\t\r\n");
      out.write("\t\tif(reName.test(document.form.name.value)){\r\n");
      out.write("\t\t\tdocument.getElementById(\"name\").innerHTML = 'Correct';\r\n");
      out.write("\t\t\treturn true\r\n");
      out.write("\t\t}else{\t\r\n");
      out.write("\t\t\tif(document.form.name.value == \"\"){\t\r\n");
      out.write("\t\t\t\tdocument.getElementById(\"name\").innerHTML = 'Enter your full name';\t\r\n");
      out.write("\t\t\t\treturn false;\t\t\t\r\n");
      out.write("\t\t\t}else {\r\n");
      out.write("\t\t\t\t\tdocument.getElementById(\"name\").innerHTML = 'Invalid Name';\r\n");
      out.write("\t\t\t\t\tform.name.focus();\r\n");
      out.write("\t\t\t\t\treturn false;\r\n");
      out.write("\t\t\t\t}\t\r\n");
      out.write("\t\t\t\r\n");
      out.write("\t\t}\r\n");
      out.write("\t}\t\r\n");
      out.write("\t\r\n");
      out.write("\tfunction testSex(){\r\n");
      out.write("\t\tif((document.form.sex[0].checked == false) && (document.form.sex[1].checked == false)){\r\n");
      out.write("\t\t\tdocument.getElementById(\"sex\").innerHTML = ' Please select your gender!';\t\r\n");
      out.write("\t\t\treturn false;\r\n");
      out.write("\t\t}else if((document.form.sex[0].checked == true) || (document.form.sex[1].checked == true)){\r\n");
      out.write("\t\t\tdocument.getElementById(\"sex\").innerHTML = ' Selected!'\r\n");
      out.write("\t\t\treturn true;\r\n");
      out.write("\t\t}\r\n");
      out.write("\t}\r\n");
      out.write("\t\r\n");
      out.write("\tfunction testZodiac(){\r\n");
      out.write("\t\tvar reZodiac = /^[A-Z][a-z]+$/\r\n");
      out.write("\t\tif(reZodiac.test(document.form.zodiac.value)){\r\n");
      out.write("\t\t\tdocument.getElementById(\"zodiac\").innerHTML = 'Correct Format';\r\n");
      out.write("\t\t\treturn true;\r\n");
      out.write("\t\t}else{\t\r\n");
      out.write("\t\t\tif(document.form.zodiac.value == \"\"){\t\r\n");
      out.write("\t\t\t\tdocument.getElementById(\"zodiac\").innerHTML = 'Enter your Zodiac';\t\r\n");
      out.write("\t\t\t\treturn false\t\t\t\r\n");
      out.write("\t\t\t}else {\r\n");
      out.write("\t\t\t\t\tdocument.getElementById(\"zodiac\").innerHTML = 'Invalid Zodiac Format';\r\n");
      out.write("\t\t\t\t\tform.zodiac.focus();\r\n");
      out.write("\t\t\t\t\treturn false;\r\n");
      out.write("\t\t\t\t}\t\r\n");
      out.write("\t\t\t\r\n");
      out.write("\t\t}\r\n");
      out.write("\t}\r\n");
      out.write("\tfunction formSubmit(){\t\t\t\t\r\n");
      out.write("\t\ta = testName();\r\n");
      out.write("\t\tb = testSex();\r\n");
      out.write("\t\tc = testZodiac();\r\n");
      out.write("\t\tif(a == true && b == true&& c == true){\t\t\t\r\n");
      out.write("\t\t\treturn true;\r\n");
      out.write("\t\t}else{\t\t\t\t\t\t\r\n");
      out.write("\t\t\treturn false;\r\n");
      out.write("\t\t\t\t\t\r\n");
      out.write("\t\t}\t\t\r\n");
      out.write("\t}\r\n");
      out.write("\tfunction formReset(){\r\n");
      out.write("\t\twindow.event.returnValue = false;\r\n");
      out.write("\t\tif(confirm(\"Are you sure to submit\"))\r\n");
      out.write("\t\t\twindow.event.returnValue = true;\r\n");
      out.write("\t}\r\n");
      out.write("\t\t\r\n");
      out.write("\tfunction displayHoroscope(){\t\t\r\n");
      out.write("\t\t\r\n");
      out.write("\t\tform1 = document.forms(\"form\");\r\n");
      out.write("\t\t\r\n");
      out.write("\t}\r\n");
      out.write("</SCRIPT>\r\n");
      out.write("</HEAD>\r\n");
      out.write("<body>\r\n");
      out.write("\t<P>Hello Welcome!</P>\r\n");
      out.write("\t<P>Please set your personal information to see the Horoscope result:</P>\r\n");
      out.write("\t<FORM NAME = \"form\" ONSUBMIT = \"return formSubmit()\" ACTION = \"http://localhost:8080/JSS/JSS\" method = \"post\"\r\n");
      out.write("\tONRESET = \"formReset()\">\r\n");
      out.write("\t\t<P>Input your name: <INPUT TYPE=\"TXT\" NAME=\"name\" ONBLUR = testName()>\r\n");
      out.write("\t\t\t\t\t\t\t<font color = red></font>\r\n");
      out.write("\t\t\t\t\t\t\t<a id = \"name\"></a></P>\r\n");
      out.write("\t\t<P>Input your sex: <INPUT TYPE=\"RADIO\" NAME=\"sex\"  VALUE=\"Male\" ONBLUS=testSex()> Male\r\n");
      out.write("\t\t   \t\t\t\t   <INPUT TYPE=\"RADIO\" NAME=\"sex\"  VALUE=\"Female\" ONBLUS=testSex()> Female\r\n");
      out.write("\t\t   \t\t\t\t   <font color = yellow></font>\r\n");
      out.write("\t\t   \t\t\t\t   <a id = \"sex\"></a></P>\r\n");
      out.write("\t\t                 \r\n");
      out.write("\t\t<P>Input your Zodiac: <INPUT TYPE=\"TXT\" NAME=\"zodiac\" ONBLUR = testZodiac()>\r\n");
      out.write("\t\t\t\t\t\t\t  <font color = blue></font>\r\n");
      out.write("\t\t\t\t\t\t\t  <a id = \"zodiac\"></a></P>\r\n");
      out.write("\t\t<P><INPUT TYPE=\"submit\" VALUE=\"Submit\" ONBLUR=>\r\n");
      out.write("\t\t   <INPUT TYPE=\"reset\" VALUE=\"Reset\" ONFUCUS=\"\"></P>\r\n");
      out.write("\t</FORM>\r\n");
      out.write("</body>\r\n");
      out.write("</html>");
    } 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 + -