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

📄 customrequestprocessor.java

📁 the musiccollection struts 1 application i netbeans implementation (strut for dummies book source)
💻 JAVA
字号:
package dummies.struts.music;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.RequestProcessor;

/**
 * @author Mike Robinson
 *
 */
public class CustomRequestProcessor extends RequestProcessor
{
	/**
	 * Handles validating of each user request, insuring that
	 * the user has logged in properly. If not, they get re-directed
	 * to the login page.
	 */
	protected boolean processPreprocess(HttpServletRequest request,
										HttpServletResponse response)
	{
		boolean continueProcessing = true;
		
		// Test if the request is a login request
		try
		{
			HttpSession session = null;
			// make sure session has not timed out
			if(request.isRequestedSessionIdValid())
				session = request.getSession();
			else
				response.sendRedirect("home.jsp?invalid=yes");						
			
			// get the current request path
			String path = processPath(request, response);
	
			// if user is not trying to logon or join, make sure user has been authenticated
			if ((!path.equals((String) "/home"))&&( !path.equals((String) "/join")))
			{
				// get the user bean
				UserDTO user = (UserDTO) session.getAttribute("user");
		
				// insure user has logged on
				if (user == null)	// else make them logon first
				{
					try
					{
						response.sendRedirect("home.jsp?invalid=yes");						
					}
					catch(Exception ioe)
					{
						log.error("problem redirecting in processPreprocess - " + ioe.getMessage());
					}
					continueProcessing = false;
				}
			}
		}
		catch(Exception ioe)
		{
			log.error("problem processing path - " + ioe.getMessage());
			continueProcessing = false;
		}

		return continueProcessing;
	}
}

⌨️ 快捷键说明

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