java web 实验五 juqery实验

     实验要求:

     编写一个注册信息填写界面,使用jQuery和JavaScript处理输出的信息,该页面能完成多种信息检查,并能利用jQuery发送Ajax请求。

使用的idea开发,下面是源码 

JQueryRegister.jsp

<%--
  Created by IntelliJ IDEA.
  User: 99631
  Date: 2018/11/14 0014
  Time: 11:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>


    Title


xx班级同学信息注册系统



姓名:
密码:
确认密码:
性别:
邮箱:
宿舍:
同意本系统使用协议查看使用协议


<%--JavaScript--%>

Register.java

 

package servlets;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/Register")
public class Register extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
               PrintWriter out = response.getWriter();

              String username=request.getParameter("username");
              String sex=request.getParameter("sex");
              String email=request.getParameter("email");
              String house=request.getParameter("house");
              String room=request.getParameter("room");
              String statu=request.getParameter("statu");

              if (statu.equals("user")) {
                  //判断username
                  if (username.length() < 4) {

                      out.println("");

                  } else {
                      if (username.equals("zhangsan") || username.equals("lisi")) {
                          out.println("");

                      } else {
                          out.println("");

                      }
                  }
              }
        if(statu.equals("form")) {
            out.println(username + ",您好,现在的时间是" + new java.util.Date());
            out.println("
您的注册信息如下"); out.println("
姓名:" + username); out.println("
性别:" + sex); out.println("
邮箱:" + email); out.println("
楼号:" + house); out.println("
宿舍号:" + room); } } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { doGet(req, resp); } }

 

你可能感兴趣的:(java)