Wrox Home  
Search P2P Archive for: Go

  Return to Index  

servlets thread: Proxy Servlet Methods


Message #1 by Gearard Boland <gboland@s...> on Wed, 13 Mar 2002 14:25:11 -0500
Hi all-

I am writing a proxy servlet for an application that I am writing.  I
have the following functions:
HttpProxyServlet()
{
//What would go here??
}
void doGet(HttpServletRequest request, HttpServletResponse response)
{
//What would go here??
}
void doPost(HttpServletRequest request, HttpServletResponse response)
{
//What would go here??
}
void init()
{
//What would go here??
}
public HttpRequestWriter getRequest(HttpRequestReader reader,
HttpServletResponse response)
  throws ServletException, IOException
 { //Create a request to be passed on by the proxy.
  HttpRequestWriter writer = null;
  if (isInvalidRequest(reader))
  {
   response.sendError(404, "Invalid request to this proxy");
  }
  else
  {
   writer = new HttpRequestWriter(reader);
   writer.setURL("/path/to/proxy/request.html");
  }
  return writer;
 }

 public HttpResponseWriter getResponse(HttpServletResponse response)
  throws ServletException, IOException
 { //Creates a response for the browser, based on the response received
from the proxied request.
    return new HttpResponseWriter(response);
 }

I came up with these through surfing the net and going through a lot of
pages claiming to explain it.  However, I am still a little confused.
If anyone could let me know what would go in the functions I mentioned
above, it would be a great help.  Or even letting me know where I could
get an example proxy servlet that works.  I also need to add a call to
another function that I wrote for every request that comes in.  Which
function(s) would I put something like that in??

Thanks a lot,
Gearard


  Return to Index