I am to implement a requirement where in there are some html files placed on an FTP location. I have to create a web application, where a particular user will login and click a link. On click, the application should get the Home HTML from the FTP location and display in the browser. In the Home HTML again there are links to other HTML's on that FTP folder.
I tried using the using anchor tag in JSP, but that doesn't work. Can anyone suggest how to achieve this functionality?
Basically problem is Home HTML has internal links to other htmls. These html are lying on the ftp location (not on the web application) server. And the Home HTML has relative path given to these htmls.
Thus when you click on any hyperlink of Home HTML, it tries to locate the html on the ROOT node of web application.
- How to ensure it tries to pull the next html from ftp location.
In effect what you are after is a proxy to an ftp site, so that the html files there can be served as if the ftp site was an http server.
Sounds convoluted to me... A huge overhead for what gain?
So you need a servlet which can connect to this ftp site, download the resource you want from it, and then send that resource out in the Response.
This servlet will also need to be invoked on links from this downloaded page.
One servlet can be configured to handle all the requests. I would approach it in this fashion:
Configure a servlet filter to dispatch all requests going to /ftp/* to the "ftp servlet", and then use the remaining part of the request to determine what resource to download from the ftp site.
e.g. accessing /myWebapp/ftp/pageFromFTPSite.html would invoke the "ftp" servlet, and load "pageFromFTPSite.html"
Thanks for your help. My pages are coming up properly, each hyperlink working fine. But I'm left with one problem.
My pages have image tags too and these images are also lying on ftp server. And clue that i have got is you cannot return content type as HTML and Image in one response from servlet. So my assumption is I need to write another servlet that is invoked when html page is rendered on browser.
I'd do the following:
1. Return the html page from servlet1.
2. Content returned by servlet1 will have image tags like <img src="xdoimgFv.png">
3. When html page is being rendered on encountering img tag, servlet 2 will be invoked.
4. Servlet 2 will download the image from ftp and return the response object as image.
Is this thought correct?
Any pointers or source code will be really helpful. I'm new to servlet programming thus any sort of information will help.