Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  //
  //  ========================================================================
  //  Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
  //  ------------------------------------------------------------------------
  //  All rights reserved. This program and the accompanying materials
  //  are made available under the terms of the Eclipse Public License v1.0
  //  and Apache License v2.0 which accompanies this distribution.
  //
  //      The Eclipse Public License is available at
 //      http://www.eclipse.org/legal/epl-v10.html
 //
 //      The Apache License v2.0 is available at
 //      http://www.opensource.org/licenses/apache2.0.php
 //
 //  You may elect to redistribute this code under either of these licenses.
 //  ========================================================================
 //
 
 package org.eclipse.jetty.server.handler;
 
 
 
 
 /* ------------------------------------------------------------ */
Moved ContextHandler. This context can be used to replace a context that has changed location. Requests are redirected (either to a fixed URL or to a new context base).
 
 public class MovedContextHandler extends ContextHandler
 {
     final Redirector _redirector;
     boolean _discardPathInfo;
     boolean _discardQuery;
     boolean _permanent;
     String _expires;
 
     public MovedContextHandler()
     {
         =new Redirector();
         setHandler();
         setAllowNullPathInfo(true);
     }
     
     public MovedContextHandler(HandlerContainer parentString contextPathString newContextURL)
     {
         super(parent,contextPath);
         =newContextURL;
         =new Redirector();
         setHandler();
     }
 
     public boolean isDiscardPathInfo()
     {
         return ;
     }
 
     public void setDiscardPathInfo(boolean discardPathInfo)
     {
          = discardPathInfo;
     }
 
     public String getNewContextURL()
     {
         return ;
     }
 
     public void setNewContextURL(String newContextURL)
     {
          = newContextURL;
     }
 
     public boolean isPermanent()
     {
         return ;
     }
 
     public void setPermanent(boolean permanent)
     {
          = permanent;
     }
 
     public boolean isDiscardQuery()
     {
         return ;
     }
 
     public void setDiscardQuery(boolean discardQuery)
     {
          = discardQuery;
    }
    
    private class Redirector extends AbstractHandler
    {
        public void handle(String targetRequest baseRequestHttpServletRequest requestHttpServletResponse responsethrows IOExceptionServletException
        {
            if (==null)
                return;
            String path=;
            if (! && request.getPathInfo()!=null)
                path=URIUtil.addPaths(pathrequest.getPathInfo());
            
            StringBuilder location = URIUtil.hasScheme(path)?new StringBuilder():baseRequest.getRootURL();
            location.append(path);
            if (! && request.getQueryString()!=null)
            {
                location.append('?');
                String q=request.getQueryString();
                q=q.replaceAll("\r\n?&=","!");
                location.append(q);
            }
            
            response.setHeader(.,location.toString());
            if (!=null)
                response.setHeader(.,);
            
            response.setContentLength(0);
            baseRequest.setHandled(true);
        }
        
    }
    /* ------------------------------------------------------------ */
    

Returns:
the expires header value or null if no expires header
    public String getExpires()
    {
        return ;
    }
    /* ------------------------------------------------------------ */
    

Parameters:
expires the expires header value or null if no expires header
    public void setExpires(String expires)
    {
         = expires;
    }
New to GrepCode? Check out our FAQ X