Java tutorial
//------------------------------------------------------------------------- // Copyright (c) 2000-2010 Digital. All Rights Reserved. // // This software is the confidential and proprietary information of // Digital // // Original author: qingang // //------------------------------------------------------------------------- // LOOSOFT MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF // THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A // PARTICULAR PURPOSE, OR NON-INFRINGEMENT. UFINITY SHALL NOT BE // LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, // MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. // // THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS ON-LINE // CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE // PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT // NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT LIFE // SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE // SOFTWARE COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SEVERE // PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES"). UFINITY // SPECIFICALLY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR // HIGH RISK ACTIVITIES. //------------------------------------------------------------------------- package com.gm.machine.filter; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.xwork.StringUtils; import cn.common.lib.util.web.RequestUtils; /** * * ??url * * @author qingang * @version 1.0 * @since 2012-12-12 */ public class CurrentUrlFilter implements Filter { public static final String CURREQUESTURL = "curRequestUrl"; /** * Filters requests to disable URL-based session identifiers. */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { // skip non-http requests if (!(request instanceof HttpServletRequest)) { chain.doFilter(request, response); return; } HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; //fromUrl??????? String webUrl = RequestUtils.getAppURL(httpRequest); //System.out.println("weburl-------------------"+webUrl); String returnUrl = httpRequest.getParameter("returnurl"); if (webUrl != null && StringUtils.isNotBlank(returnUrl)) { //System.out.println("returnurl-------------------"+returnUrl); httpRequest.getSession().setAttribute(CURREQUESTURL, returnUrl); } else { // set current request url into request as a attribute httpRequest.getSession().setAttribute(CURREQUESTURL, webUrl); } // process next request in chain chain.doFilter(request, httpResponse); } @Override public void destroy() { // TODO Auto-generated method stub } @Override public void init(FilterConfig filterConfig) throws ServletException { // TODO Auto-generated method stub } }