• Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to load file stored in file system  RSS feed

Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

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

Even file is present there ,it says not able to load.
It is searching witn in the war file which is

Please suggest any body what i am missing over here.

[ May 30, 2008: Message edited by: Bear Bibeault ]
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.

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!