• Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to load file stored in file system

 
Veena Grandhi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!