If your files are static and it isn't protected content, so there is no reason to use servlet for getting them. Your web server will do this job nicely and faster. Check you web server manual how to define aliases. You can also use SUBST Windows command to map another drive to a directory served under your servlet container, however this way smells as a hack.
Well, if you still insist on using RequestDispatcher to load the file up, you can try the following approach.
Deploy another web application to the same Web Container (In this case, to the same WebSphere instance). This web application will contain all the content files that you wanna load. And you can deploy it to another drive.
Then in your original web application, use ServletContext.getContext to get the ServletContext of the new application and subsequently use that to get the RequestDispatcher that load the text file you desired.
It's a way I thought off. Cheers. [ October 28, 2006: Message edited by: Eddy Lee Sin Ti ]
SCJP, SCWCD, SCJWS, IBM 700,IBM 701, IBM 704, IBM 705, CA Clarity Technical<br /> <br /><a href="http://eddyleesinti.blogspot.com" target="_blank" rel="nofollow">http://eddyleesinti.blogspot.com</a>
Joined: Oct 27, 2006
Thanks for the replies!!
These are my concerns: 1. Minimal code change. (system is in production) 2. To know how existing systems are handling issues similar to mine. 3. Security issues .(system mainted by separate team)
The reason for RequestDispatcher was to avoid code change, But after some persuation we can now do away with it.
I can't use the shared drive into container concept for security reasons.
The second system is a system in network with HDD space, It has no server deployed on it. We can deploy nothing on it.
I looked around in the forum and found a "file upload thread". So, i can use FileInputStream, But now i need to do it over network.
Question: -------------- 1. Is opening a socet the only way to read file over network? e.g The file is at host ort/drive/filename.txt
2. One of the replies has "Check you web server manual how to define aliases" - What alias can be set in the server? is it for URL?
Thanks and Regards, Shailesh
Eddy Lee Sin Ti
Joined: Oct 06, 2005
If URL is the only way allowed to access the resources, you can use the java.net.URL, then use the openConnection() method to create an URLConnection instance and subsequently retrieve the InputStream. Just need to make sure the security is properly configured.
Hope this helps. Cheers.
Joined: Oct 27, 2006
Thanks a lot for the answering the queries.!!
With everything pretty much clear only a clean implementation remains.
But if i may ask another question : 1. What would be the best way to solve such issues of space? (no restrictions, But i think the new HDD has to be in common place for clustered access) 2. Has anybody got a different idea.?
But I must metion again , The questions are purely for theoretical purposes.