The first Java EE program

Source: Internet
Author: User

<! DOCTYPE HTML Public"-//w3c//dtd HTML 4.01 transitional//en">"keywords"Content="Keyword1,keyword2,keyword3"> <meta http-equiv="Description"Content="This is my page"> <meta http-equiv="Content-type"Content="text/html; Charset=utf-8"> <!--<link rel="stylesheet"Type="Text/css"href="./styles.css">-->  This isMy HTML page. <br> <form method="Get"action=" First">UserName:<input type="text"Name="UserName"/><br/>Password:<input type="text"Name="Password"/><br/> <input type="Submit"Value="Login"/> </form> </body>
Package J2ee0525;import java.io.ioexception;import java.io.printwriter;import javax.servlet.ServletException; Import Javax.servlet.http.httpservlet;import Javax.servlet.http.httpservletrequest;import Javax.servlet.http.HttpServletResponse; Public classFirstserve extends HttpServlet {/** * The Doget method of the servlet. <br> * * This method was called when a form have its tag value me     Thod equals to get.  * * @param request the request send by the client to the server * @param response the response send by the server To the client * @throws servletexception If a error occurred * @throws IOException If an error occurred */     Public voiddoget (httpservletrequest request, httpservletresponse response) throws Servletexception, IOException { //Receiving user DataString Username=request.getparameter ("UserName"); String Password=request.getparameter ("Password"); Response.setcontenttype ("Text/html;charset=utf-8"); PrintWriter out=Response.getwriter ();  out. println ("<! DOCTYPE HTML public \ "-//W3C//DTD HTML 4.01 transitional//en\" >");  out. println ("<HTML>");  out. println ("");  out. println ("<BODY>");  out. println ("</BODY>"); //the data can be verified here.//pretending to have a databaseChectdao dao=NewChectdao (); if(Dao.check (userName, password)) { out. println ("Landing Success"); }Else{        out. println ("user name or password is wrong, please re-login"); }                 out. println ("</HTML>");  out. Flush ();  out. Close (); }    /** * The DoPost method of the servlet. <br> * * This method was called when a form have its tag value m     Ethod equals to post.  * * @param request the request send by the client to the server * @param response the response send by the server To the client * @throws servletexception If a error occurred * @throws IOException If an error occurred */     Public voidDoPost (httpservletrequest request, httpservletresponse response) throws Servletexception, IOException { Response.setcontenttype ("text/html"); PrintWriter out=Response.getwriter ();  out. println ("<! DOCTYPE HTML public \ "-//W3C//DTD HTML 4.01 transitional//en\" >");  out. println ("<HTML>");  out. println ("");  out. println ("<BODY>");  out. Print (" This is");  out. Print ( This. GetClass ());  out. println (", using the POST method");  out. println ("</BODY>");  out. println ("</HTML>");  out. Flush ();  out. Close (); }}
Package j2ee0525; Public classChectdao { Publicboolean check (String name,string password) {if(Name.equals ("Admin") && Password.equals ("123456")){            return true; }Else{            return false; }    }        }

The first Java EE program

Related Article

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.