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 Unable to load file stored in file system Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Unable to load file stored in file system" Watch "Unable to load file stored in file system" New topic
Author

Unable to load file stored in file system

Veena Grandhi
Greenhorn

Joined: Mar 13, 2008
Posts: 9
Hi,

We are having an applet talking to servlet, which inturn talks to db and is creating dynamicall y html file and storing in filesystem which are for example under
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/ATWREPORT/rpthtml

Now the applet should load that html file and it is doing as below
URL RptURL = new URL(getDocumentBase(),"rpthtml/atwRpt_30052008.html");
getAppletContext().showDocument(RptURL, "_blank");

Above lines are resulting in the following URL
http://hostname:9080/ATWREPORT/rpthtml/atwRpt_30052008.html

Even file is present there ,it says not able to load.
It is searching witn in the war file which is
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/ATWREPORT/ATWREPORT_war.ear/ATWREPORT.war/rpthtml

Please suggest any body what i am missing over here.
OS:solaris,AppServer:WAS 6.0.2.17

Regards,
Veena
[ May 30, 2008: Message edited by: Bear Bibeault ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If your app has not been deployed as an exploded file system (it's being run from a war or ear file), or, if your file is not being written to the web application's directory structure, you're not going to be able to access it from the web.

The way around this is to write a servlet that can read the file from the server's file system and stream it to the client.
We have a sample app that does something similar which might be a good starting platform for you. This app reads the file from within the WEB-INF directory using getResourceAsStream; something you won't be able to do.
If you alter it to read the file using java.io.File, you should be able to achieve the same thing.

See:
http://faq.javaranch.com/java/CodeBarnSimpleStream


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://jrebel.com/download
 
subject: Unable to load file stored in file system
 
Similar Threads
a servlet inside jar can not be accessed on web sphere at workplace
admin console is not working
Finding path location on server returning null
bad major version at offset=6
Node Federation error