⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 forcelogin.jsp

📁 java 的164个例子的源代码,包括了 很多方面,供包括了19个方面的 源代码
💻 JSP
字号:
<%-- * Copyright (c) 2000 David Flanagan.  All rights reserved. * This code is from the book Java Examples in a Nutshell, 2nd Edition. * It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied. * You may study, use, and modify it for any non-commercial purpose. * You may distribute it non-commercially as long as you retain this notice. * For a commercial use license, or to purchase the book (recommended), * visit http://www.davidflanagan.com/javaexamples2.--%><%--forcelogin.jsp  This is a fragment of JSP code.  It cannot stand alone, but is  intended to be included within other JSP pages.  It looks for a  "username" attribute in the Session object, and if it does not find  one, it forwards the request to the login.jsp page, which will  authenticate the user and store their name in the session object.  This code sends a "nextpage" request parameter to the login.jsp, so  that the login page knows where to return to once the user has  successfully logged in.  Note that request parameters passed to this  page are not preserved when the login page redirects back to this page.--%><%// Check whether the username is already defined in the Session objectString _username = (String) session.getAttribute("username");if (_username == null) {  // If the user has not already logged in   String _page = request.getRequestURI();%><%-- Invoke the login.jsp page.  The <jsp:forward> tag invokes the  --%><%-- page directly on the server side without sending a redirect --%><%-- to the client The <jsp:param> tags specify request parameters --%><%-- that are passed to login.jsp --%><jsp:forward page='login.jsp'>      <jsp:param name='nextpage' value='<%=_page%>'/>    <jsp:param name='title'               value='<%= "You must log in to access " + _page%>'/></jsp:forward><%}%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -