SESSION prohibits not logging in to browse information

xiaoxiao2021-03-06  77

Key words: session, redirection. Analysis Login.htm: Responsible for accepting user input information, such as user name and password. Login.jsp: Responsible for accepting the data submitted by the login.htm and connects to the legality of the database for user identity. REOGIN.HTM: Responsible for users re-enter. Info.jsp: Users legally log in and redirected to the page after approved by the system. The user enters information in login.htm and submits a post-handed login.jsp processing, if legal, redirect to INFO.jsp; if you do not legally redirect to Relogin.htm re-login, where the list of action is: Action = " Login.jsp "The same as the Login.htm Action item. Judging with the session. Implementation: (1) <% in Login.jsp <% ........... // ourselves plus other code. Session.setttribute ("login", "ok"); ...... .....%> (2) in info.jsp: <%

String login = (string) session.getattribute ("login");

IF (login! = null && login.equals ("ok")) {

// do nothing;

}

Else {

Response.sendRedirect ("Relogin.htm");

}

%>

<1> Write the case in case case request setHeader SetAttribute GetAttribute String <2> Redirect common: response.sendredirect ("Relogin.htm");

转载请注明原文地址:https://www.9cbs.com/read-108857.html

New Post(0)