Package com.twelvemonkeys.servlet
Class ProxyServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- com.twelvemonkeys.servlet.GenericServlet
-
- com.twelvemonkeys.servlet.ProxyServlet
-
- All Implemented Interfaces:
java.io.Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
public class ProxyServlet extends GenericServlet
A simple proxy servlet implementation. Supports HTTP and HTTPS.Note: The servlet is not a true HTTP proxy as described in RFC 2616, instead it passes on all incoming HTTP requests to the configured remote server. Useful for bypassing firewalls or to avoid exposing internal network infrastructure to external clients.
At the moment, no caching of content is implemented.
If the
remoteServer
init parameter is not set, the servlet will respond by sending a500 Internal Server Error
response to the client. If the configured remote server is down, or unreachable, the servlet will respond by sending a502 Bad Gateway
response to the client. Otherwise, the response from the remote server will be tunneled unmodified to the client.- Version:
- $Id: ProxyServlet.java#1 $
- Author:
- Harald Kuhr, last modified by $Author: haku $
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
remotePath
Remote server "mount" pathprotected int
remotePort
Remote server portprotected java.lang.String
remoteServer
Remote server host name or IP address
-
Constructor Summary
Constructors Constructor Description ProxyServlet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
service(javax.servlet.http.HttpServletRequest pRequest, javax.servlet.http.HttpServletResponse pResponse)
Services a single request.void
service(javax.servlet.ServletRequest pRequest, javax.servlet.ServletResponse pResponse)
Overrideservice
to use HTTP specifics.void
setRemotePath(java.lang.String pRemotePath)
Called byinit
to set the remote path.void
setRemotePort(java.lang.String pRemotePort)
Called byinit
to set the remote port.void
setRemoteServer(java.lang.String pRemoteServer)
Called byinit
to set the remote server.-
Methods inherited from class com.twelvemonkeys.servlet.GenericServlet
init
-
-
-
-
Method Detail
-
setRemoteServer
public void setRemoteServer(java.lang.String pRemoteServer)
Called byinit
to set the remote server. Must be a valid host name or IP address. No default.- Parameters:
pRemoteServer
-
-
setRemotePort
public void setRemotePort(java.lang.String pRemotePort)
Called byinit
to set the remote port. Must be a number. Default is80
.- Parameters:
pRemotePort
-
-
setRemotePath
public void setRemotePath(java.lang.String pRemotePath)
Called byinit
to set the remote path. May be an empty string for the root path, or any other valid path on the remote server. Default is""
.- Parameters:
pRemotePath
-
-
service
public final void service(javax.servlet.ServletRequest pRequest, javax.servlet.ServletResponse pResponse) throws javax.servlet.ServletException, java.io.IOException
Overrideservice
to use HTTP specifics.- Specified by:
service
in interfacejavax.servlet.Servlet
- Specified by:
service
in classjavax.servlet.GenericServlet
- Parameters:
pRequest
-pResponse
-- Throws:
javax.servlet.ServletException
java.io.IOException
- See Also:
service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
-
service
protected void service(javax.servlet.http.HttpServletRequest pRequest, javax.servlet.http.HttpServletResponse pResponse) throws javax.servlet.ServletException, java.io.IOException
Services a single request. Supports HTTP and HTTPS.- Parameters:
pRequest
-pResponse
-- Throws:
javax.servlet.ServletException
java.io.IOException
- See Also:
Class descrition
-
-