org.mortbay.servlet
Class ProxyServlet

java.lang.Object
  extended by org.mortbay.servlet.ProxyServlet
All Implemented Interfaces:
Servlet
Direct Known Subclasses:
ProxyServlet.Transparent

public class ProxyServlet
extends Object
implements Servlet

Proxy Servlet.

Forward requests to another server either as a standard web proxy (as defined by RFC2616) or as a transparent proxy.


Nested Class Summary
static class ProxyServlet.Transparent
          Transparent Proxy.
 
Field Summary
protected  ServletConfig _config
           
protected  ServletContext _context
           
protected  HashSet _DontProxyHeaders
           
 
Constructor Summary
ProxyServlet()
           
 
Method Summary
 void destroy()
           
 ServletConfig getServletConfig()
           
 String getServletInfo()
           
 void handleConnect(HttpServletRequest request, HttpServletResponse response)
           
 void init(ServletConfig config)
           
protected  URL proxyHttpURL(String scheme, String serverName, int serverPort, String uri)
          Resolve requested URL to the Proxied URL
 void service(ServletRequest req, ServletResponse res)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_DontProxyHeaders

protected HashSet _DontProxyHeaders

_config

protected ServletConfig _config

_context

protected ServletContext _context
Constructor Detail

ProxyServlet

public ProxyServlet()
Method Detail

init

public void init(ServletConfig config)
          throws ServletException
Specified by:
init in interface Servlet
Throws:
ServletException

getServletConfig

public ServletConfig getServletConfig()
Specified by:
getServletConfig in interface Servlet

service

public void service(ServletRequest req,
                    ServletResponse res)
             throws ServletException,
                    IOException
Specified by:
service in interface Servlet
Throws:
ServletException
IOException

proxyHttpURL

protected URL proxyHttpURL(String scheme,
                           String serverName,
                           int serverPort,
                           String uri)
                    throws MalformedURLException
Resolve requested URL to the Proxied URL

Parameters:
scheme - The scheme of the received request.
serverName - The server encoded in the received request(which may be from an absolute URL in the request line).
serverPort - The server port of the received request (which may be from an absolute URL in the request line).
uri - The URI of the received request.
Returns:
The URL to which the request should be proxied.
Throws:
MalformedURLException

handleConnect

public void handleConnect(HttpServletRequest request,
                          HttpServletResponse response)
                   throws IOException
Throws:
IOException

getServletInfo

public String getServletInfo()
Specified by:
getServletInfo in interface Servlet

destroy

public void destroy()
Specified by:
destroy in interface Servlet


Copyright © 1995-2010 Mort Bay Consulting. All Rights Reserved.