Saturday, February 15, 2014

Making image available via url on tomcat

So I needed to make my tomcat server to give access from the url, something like: http://your_server_name/image_folder/image.png.

So what you need to do is to add path to your tomcat sever.xml file. If you using eclipse you should have a server project in your workspace, here is how it should be looked (yours would be probably called just Servers):
If you are not using eclipse find this file in your system.

Open this file (marked in blue on the image) and add this line of code in under your <host> tag:

 <Context docBase="full_path_to_image_folder" path="/image" />  

Note: full_path_to_image_folder  is something like C:/images.

After this just reset your tomcat server and try to access some image via your browser, here is an example:


 http://localhost:8080/image/my_image.png  

You may need to restart your machine in order for the changes will take their place.

No comments:

Post a Comment