I want to access an image file(which is outside the war file where the folder of image file is protected by credentials)from a war file where the image file and war file are located in the same server.
Anyone please help me?
Thanks in advance.
regards, sudha.
Sivaraman Lakshmanan
Ranch Hand
Joined: Aug 02, 2003
Posts: 231
posted
0
Hi Sudha, Is the war file and the image file are in the same directory? If yes and if you are able to access the war file you should be able to access the image file as well.
Regards,
Sivaraman.L
Rajah Nagur
Ranch Hand
Joined: Nov 06, 2002
Posts: 239
posted
0
Originally posted by Sudha Govindarajan: Hi,
I want to access an image file(which is outside the war file where the folder of image file is protected by credentials)from a war file where the image file and war file are located in the same server.
Anyone please help me?
Thanks in advance.
regards, sudha.
Have you tried accessing this? Are you getting any error? What is your approach that has been attempted?
You can't wake a person who is <b><i>pretending</i></b> to be asleep.<br />Like what <b>"it"</b> does not like - <i> Gurdjieff </i>
We have a project in our CodeBarn named SimpleStream that shows how to make a servlet for streaming binary data (in this case images) to the client.
In the demo project, the files are being read with context.getResourceAsStream. You won't be able to do this if the files are outside of your web application's directory structure. You'll need to change it to use a FileReader.
This should be enough to get you on the right track.
How about <c:import> jstl tag? It can access a URL even if the resource is on other server. Please correct me if i am wrong.
thanks Raj
Bauke Scholtz
Ranch Hand
Joined: Oct 08, 2006
Posts: 2458
posted
0
The SimpleStream example isn't very suitable as it relies on the classpath. You either have to add the path to the images to the classpath, or to use FileInputStream (and thus certainly not FileReader) to read imags from local disk.
About the JSTL's c:import tag: this is not suitable either. It can only access resources in own context, or the other contexts, or just by an external (absolute) URL.