Javaweb Landing Registration Page

Source: Internet
Author: User


Data modification of the view, also modified in the table
Reference tool class with <%@ page import= ""%>

<%@ page import="java.util.Date" %><%@ page import="  Java.text.SimpleDateFormat" %>

The introduction package can be written in a single piece, or it can be separated by commas in a single line.

<%@ page import="" %>

Application.getattribute is a key-value pair ...
Strong turn

Object GetAttribute (string name): Gets the specified property
Enumeration Getattributenames (): Gets the names of all the properties that comprise the enumeration
RemoveAttribute (string name): Removes the specified property
void setattribute (String name,object o): Setting properties

Pagecontext,request,session,application, all have these methods to become scope objects


PageContext: The scope of the property is limited to the current page
Request: limited to the same requests
Session: Only one reply, browser open until closed called a reply (reply does not expire)
Application: The scope of the property is limited to the current Web application, is the largest, as long as the property is set in one place, can be obtained in all other places

Login Registration Example

Home page:

<%@ 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">Object obj=session.getattribute ("CurrentUser"); if(obj==NULL) {Response.sendredirect ("login.jsp"); }%><meta http-equiv="Content-type"Content="text/html; Charset=utf-8"><title>insert title Here</title>"login.jsp"><input type="Button"Name="Login"Value="Login"/></a> <br> <a href="resist.jsp"><input type="Button"Name="Resist"Value="Register"/></a></body>
<%@ 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">"Content-type"Content="text/html; Charset=utf-8"><title>insert title Here</title>"operation.jsp"Method="Post"> <input type="text"Name="username"Placeholder="Please enter user name"/><br> <input type="text"Name="Password"Placeholder="Please enter your password"/><br> <input type="text"Name="Password1"Placeholder="Please enter your password again"/><br> <a href="login.jsp"><input type="Submit"Value="Register"/></a> </form> </body>
<%@ page language="Java"Contenttype="text/html; Charset=utf-8"pageencoding="UTF-8"%> <%@ Page import="textloginresist. User"%><! DOCTYPE HTML Public"-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD">"Content-type"Content="text/html; Charset=utf-8"><title>insert title Here</title>String username=request.getparameter ("username"); String Password=request.getparameter ("Password"); String Password1=request.getparameter ("Password1"); if(Password.equals (Password1)) {Object o=Application.getattribute (username); if(o!=NULL){                 out. Print ("user already exists"); }Else{User u=NewUser ();                U.setusername (username);                U.setpassword (password);            Application.setattribute (username, u); }        }Else{             out. Print ("two input inconsistencies"); }         out. Print ("Registration Successful");  out. Print ("<a href= ' login.jsp ' > jump page </a>"); %></body>

Landing:

<%@ 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">"Content-type"Content="text/html; Charset=utf-8"><title>insert title Here</title>"operationlogin.jsp"Method="Post"> <input type="text"Name="username"Placeholder="Please enter user name"/><br> <input type="text"Name="Password"Placeholder="Please enter your password"/><br> <a href="index.jsp"><input type="Submit"Value="Login"/></a> </form> </body>
<%@ page language="Java"Contenttype="text/html; Charset=utf-8"pageencoding="UTF-8"%> <%@ Page import="textloginresist. User"%><! DOCTYPE HTML Public"-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD">"Content-type"Content="text/html; Charset=utf-8"><title>insert title Here</title>String username=request.getparameter ("username"); String Password=request.getparameter ("Password"); if(username!=NULL) {User u=(User) Application.getattribute (username); if(Username.equals (U.getusername ())) {if(Password.equals (U.getpassword ())) {Session.setattribute ("CurrentUser", u);//Prevent users from landing into home response.sendredirect ("index.jsp"); }Else{                         out. Print ("Password Error"); }                }Else {                     out. Print ("user does not exist! ");  out. Print ("<a href= ' login.jsp ' > jump page </a>"); }            }Else{                 out. Print ("wrong input"); }        %></body>

Javaweb Landing Registration Page

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.