How to use External Directory to Store Images.
And how i access that images thru my Web application ?
- I am using Jboss as an application Server.
- Web application is in Java,Jsp.
- Presently images stored in WAR file.
After google i got the solution
C:\jboss-4.0.0\server\default\deploy\jbossweb-tomcat55.sar\server.xml
Then restart the server and access the
htt开发者_JS百科p://localhost:8080/contextname/images
Please provide comments
I've answered similar question before: Simplest way to serve static data from outside the application server in a Java web application
To summarize there are basically two ways:
Add a new
Context
to theserver.xml
denoting the absolute location where the images are.Create a
Servlet
which gets anInputStream
of the image usingFileInputStream
and writes it the usual Java IO way to theOutputStream
of the response, along with at leastContent-Type
,Content-Length
andContent-Disposition
headers.
See the link for more detailed answers and code examples.
精彩评论