Servlet exercises a simple registration

Source: Internet
Author: User

<%@ Page Language="Java"ContentType="text/html; Charset=utf-8"pageencoding="UTF-8"%><!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd "><HTML><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"><title>Insert Title here</title></Head><Body>Register<formAction= "Zhucservlet"Method= "POST">User name<inputtype= "text"name= "username"><BR>Password<inputtype= "Password"name= "Password"><BR>Confirm Password<inputtype= "Password"name= "Password1"><BR><inputtype= "Submit"value= "Submit"></form></Body></HTML>
 PackageCom.hanqi.web;Importjava.io.IOException;ImportJava.io.PrintWriter;Importjavax.servlet.ServletException;ImportJavax.servlet.http.Cookie;ImportJavax.servlet.http.HttpServlet;Importjavax.servlet.http.HttpServletRequest;ImportJavax.servlet.http.HttpServletResponse;Importjavax.servlet.http.HttpSession; Public classZhucservletextendsHttpServlet {Private Static Final LongSerialversionuid = 1L;  PublicZhucservlet () {Super(); }        protected voidDoget (HttpServletRequest request, httpservletresponse response)throwsservletexception, IOException {response.setcontenttype ("Text/html"); Response.setcharacterencoding ("UTF-8"); String un=request.getparameter ("username"); String PW=request.getparameter ("Password"); String PW1=request.getparameter ("Password1"); if(un!=NULL&&pw!=NULL)        {            if(pw!= "" &&un!= "")            {            if(Pw.equals (PW1)) {String n=NewString (Un.getbytes ("iso-8859-1"), "UTF-8"); Response.getwriter (). Write (n+ "Congratulations on the success of registration"); }            Else{response.getwriter (). Write ("Please confirm the password is consistent"); }            }            Else{response.getwriter (). Write ("User name or password cannot be empty"); }        }        Else{response.getwriter (). Write ("User name or password cannot be empty"); }        //response.getwriter (). Append ("Served at:"). Append (Request.getcontextpath ());    }        protected voidDoPost (HttpServletRequest request, httpservletresponse response)throwsservletexception, IOException {doget (request, response); }}

Servlet exercises a simple registration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.