• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to store a file on server

 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Thanks a lot in advance.
We will deploy the application on websphere server through URL which is at remote place by creating ear file.
Now, I have on pdf file which is a fixed one and it wont be changed in future also and I am opening this pdf on click of a link.
Due to this large pdf my ear size become very high and some times I am facing deployment problem while uploading this large file.
Is there any way to keep the file some where in server and later we can open?.

Please help me.
Regards,
Sree
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can write a servlet that streams binary files from the server to the browser. Then, using a context init param, you can configure the location of the file so that your streaming servlet can find it.

If you would like an example of a servlet that streams a file, we have one in our Code barn.
http://www.javaranch.com/codebarn/codebarn-servlets-simplestream.jsp

In this example, the files are being read using ServletContext.getResourceAsStream because they are located within the web app's directory structure. In your case, you would want to use a FileReader so you can read the file from disk using java.io.File.
It shouldn't be hard to convert the example servlet to do that.
 
sridhar lakka
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for your reply, however I dont want to store that file even in WEB-INF folder, as it will when we will create an ear.

Regards,
Sree
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know. You said that.
This is why I said:

In your case, you would want to use a FileReader so you can read the file from disk using java.io.File.
It shouldn't be hard to convert the example servlet to do that.

 
Arch enemy? I mean, I don't like you, but I don't think you qualify as "arch enemy". Here, try this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic