02_06 JSP built-in object session

Source: Internet
Author: User
Tags session id

I. Introduction of the SESSION

The main function of the Sessiond object is to complete the user's logon, logoff and other operations, each session object represents a different access user. The session object is an instantiated object of the Javax.servlet.http.HttpSession interface. The common methods are:

no

3

1 2 4 5

description

public String  getid ()

get ID

public long GetCreationTime ()

Get creation time

get last operation time

public Boolean  isnew ()

determine if new user

public void  invalidate ()

let session expire

6

Public enumeration Getattributenames ()

Get all property names

Second, get the session Id

<%@ pagecontenttype= "text/html" pageencoding= "GBK"%>


Third, login and cancellation (important)

1. Login and logout

LOGIN.JSP:

Complete the display of the login form and submit data to this form. If the login succeeds, the property is saved, and if it fails, the logon failure message is displayed.

WELCOME.JSP:

After the user login successfully can display information, if not logged in, you want to give a message not logged in, at the same time give the login connection address.

LOGOUT.JSP:

Complete login logout, log off after the page jumps back to the login.jsp page.

Example Login System sample

LOGIN.JSP:

<%@ page contenttype= "text/html"  pageencoding= "GBK"%>

WELCOME.JSP:

<%@ page contenttype= "text/html" pageencoding= "GBK"%>

LOGOUT.JSP:

<%@ page contenttype= "text/html" pageencoding= "GBK"%>


2. Get user operation time

<%@ page contenttype= "text/html" pageencoding= "GBK"%>



The above content reference Javaweb development actual combat Classics (teacher pulpit)


This article is from the "Beyond the Horizon" blog, be sure to keep this source http://udbful.blog.51cto.com/10601869/1683384

02_06 JSP built-in object session

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.