Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Request Dispatcher access file in another drive

 
shail shailesh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

We have a website that was supposed to open-up a text file when a link is selected.

It had been implemented using
res.getRequestDispatcher("/<folder>/a.txt");
RequestDispatcher.forward(res,resp);

But now we are running short of space in server machine and hence need to move text files to a new location (on a separate system with a different ip).

The requestDispatcher doesn't work.
e.g requestDispatcher = res.getRequestDispatcher("<ip>/<folder>/a.txt");


Questions :
-------------
1. Is there an alternateway , perhaps URL or URI method?
<i am new to servlets, it is just a guess>

2. Should Some setting be done for accessing such files?


I use Websphere and Windows OS.

Thanks and Regards,
Shailesh
 
D Rog
Ranch Hand
Posts: 472
Linux Objective C Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Eddy Lee Sin Ti
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
shail shailesh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.
 
shail shailesh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.

Thanks once again...!!!

Thanks and Regards,
Shailesh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic