File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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
 
Similar Threads
problem while Opening Excel and pdfs in JSP using Websphere Application Server 6.1
Display text file in server from client
How to create an xls file from jsp
Requests to server
Save POI Excel file in JSF