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
remoteServerinit parameter is not set, the servlet will respond by sending a500 Internal Server Errorresponse to the client. If the configured remote server is down, or unreachable, the servlet will respond by sending a502 Bad Gatewayresponse 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.StringremotePathRemote server "mount" pathprotected intremotePortRemote server portprotected java.lang.StringremoteServerRemote 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 voidservice(javax.servlet.http.HttpServletRequest pRequest, javax.servlet.http.HttpServletResponse pResponse)Services a single request.voidservice(javax.servlet.ServletRequest pRequest, javax.servlet.ServletResponse pResponse)Overrideserviceto use HTTP specifics.voidsetRemotePath(java.lang.String pRemotePath)Called byinitto set the remote path.voidsetRemotePort(java.lang.String pRemotePort)Called byinitto set the remote port.voidsetRemoteServer(java.lang.String pRemoteServer)Called byinitto set the remote server.-
Methods inherited from class com.twelvemonkeys.servlet.GenericServlet
init
-
-
-
-
Method Detail
-
setRemoteServer
public void setRemoteServer(java.lang.String pRemoteServer)
Called byinitto 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 byinitto set the remote port. Must be a number. Default is80.- Parameters:
pRemotePort-
-
setRemotePath
public void setRemotePath(java.lang.String pRemotePath)
Called byinitto 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.IOExceptionOverrideserviceto use HTTP specifics.- Specified by:
servicein interfacejavax.servlet.Servlet- Specified by:
servicein classjavax.servlet.GenericServlet- Parameters:
pRequest-pResponse-- Throws:
javax.servlet.ServletExceptionjava.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.IOExceptionServices a single request. Supports HTTP and HTTPS.- Parameters:
pRequest-pResponse-- Throws:
javax.servlet.ServletExceptionjava.io.IOException- See Also:
Class descrition
-
-