This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Servlets and the fly likes Proxy Servlet Example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Proxy Servlet Example" Watch "Proxy Servlet Example" New topic
Author

Proxy Servlet Example

marc miller
Greenhorn

Joined: Sep 12, 2003
Posts: 1
Hello out there,
my wish is to program a servlet, that takes the URL from a Request-Parameter,, then retrieves the content of the given URL and finally outputs the content to the client...
Has anyone a simple example for me?
Regards,
Marc
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

This is a very short and very contrived example, but it goes like this:
The User selects a display page from a list. The name of this display page is passed to a Servlet as a parameter. The servlet will then return the page to the client. Just to make it interesting, the Servlet also assumes that it has to prepend a directory to the JSP that the user does not know about.
I'd also like to point out that passing file names like this is a security risk since the user can write any filename into the URL. It's not a good idea to clients this sort of control.
The servlet will be mapped as /MyServlet and look like this:

and you call it like this: /MyServlet?filename=myfile.jsp or /MyServlet?filename=myfile.html
Hope this helps. It's a bit of a short example, but might get you started.
Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Proxy Servlet Example