Java implementation of an account can only be landed in one place, other places are offline

Source: Internet
Author: User

In fact, there are a lot of methods, I caught dead this.

Use the four scopes to understand Java.

Idea: The key to understanding the four main scopes of Java.

First place to land:

1. The requested SessionID and login username

2. Save the SessionID in the application, the user name is stored in the current session

        Actioncontext ac = actioncontext.getcontext ();            Map<string, object> applicationmap=ac.getapplication ();            Map<string, object> sesisonmap = ac.getsession ();
The requested SessionID String Currentseesionid= getrequest (). GetSession (). GetId (); Applicationmap.put (Loanusere.getuname (), Currentseesionid); Sesisonmap.put (Commonvar.sso_login_name_key,loanusere.getuname ());

Second place to land:

1. Get the browser's SessionId and get the login username

2. In the current session to obtain the user name corresponding keyword, with the keyword in the application to get SessionID,

For comparison, not equal to jump to landing.

Interceptors:

/**initialization parameters are obtained*/Actioncontext Actioncontext=Arg0.getinvocationcontext (); /**httpservletrequest Parameters*/HttpServletRequest Request=(HttpServletRequest) actioncontext.get (strutsstatics.http_request); /**httpservletresponse Parameters*/HttpServletResponse Response=(HttpServletResponse) actioncontext.get (strutsstatics.http_response); /**Session Parameters*/Map<string, object> sessionmap =actioncontext.getsession (); Map<string, object> appcationmap =actioncontext.getapplication (); String LoginName=NULL; //SessionID in the context objectString sessionId =NULL; if(!Sessionmap.isempty ()) {LoginName=(String) sessionmap.get (Commonvar.sso_login_name_key); } if(NULL!=loginName) {SessionId=(String) appcationmap.get (loginName); } //SessionID of the current sessionString Currentsessionid =request.getsession (). GetId (); if(!currentsessionid.equals (sessionId)) { return"Loanuserlogin"; }

Java implementation of an account can only be landed in one place, other places are offline

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.