Learn to record Java session save user Login

Source: Internet
Author: User

1<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "2pageencoding= "UTF-8"%>3<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >456<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">7<title>insert title here</title>89<body>Ten<% One  A //Check session, get session information -Object obj = Session.getattribute ("username"); - if(obj! =NULL) the { -Out.print ("Welcome login" +obj.tostring ());  - } - Else + { -Out.print ("Session timed out, please log back in to the system");  + //jump to user interface after 3 seconds AResponse.setheader ("Refresh", "3; Url=login.jsp "); at } -%> - Main Page Face -<br> -<a href= "login.jsp" > Sign out </a> -</body> in

1<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "2pageencoding= "UTF-8"%>3<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >456<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">7<title>insert title here</title>89<body>Ten Login Page One<br> A<% - //Destroy Session - session.invalidate (); the%> -  -<form action= "testpw.jsp" method = "POST" > -User name: <input type= "text" name = "username" > +Password: <input type= "password" name = "Password" > -<input type= "Submit" value= "Login" > +</form> A</body> at
<%@ 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" >//Verify that the user logon information is correctString un= Request.getparameter ("username"); String PW= Request.getparameter ("Password");if(UN! =NULL&& PW! =NULL){    //Create session if correct, and jump to main.jsp    if(Un.equals ("ASD") && pw.equals ("123"))    {        //Log User InformationSession.setattribute ("username", un); //jump to System main PageResponse.sendredirect ("main.jsp"); }    Else    {        //Otherwise, prompt for login errorOut.print ("User name or password error"); }}Else{out.print ("Please access the system in a normal way"); }%></body>

Learn to record Java session save user Login

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.