0

I need to serve images directly from a folder outside war file using tomcat server. I tried few options like setting the image location path in context docbase but its not working. I configured that in server.xml of tomcat as follows

<Context docBase="E:\images\" path="/images" />

I need a solution directly from tomcat side and cant make any code changes to serve them. Already gone through these links but of no use: How to config Tomcat to serve images from an external folder outside webapps?

Tomcat version : 8.5, my images are in .svg format. Please help me in this.

Rahul Bhobe
  • 4,165
  • 4
  • 17
  • 32
kirti
  • 4,499
  • 4
  • 31
  • 60

2 Answers2

3

This may help @Kirti or someone who is facing this problem.

I tried with following solution in same case in my project:-

  1. I created a directory on server as E:\MyProject\Images

  2. Added following <Context /> tag in server.xml inside <Host></Host> tag

    <Context docBase="E:\\MyProject\\Images" path="/images"/>

  3. Then I could simply access the images using following link:

    http://localhost:8080/images/firstImage.jpg

Note: For windows we separate path with \\ and in linux need to use //

Lalit Jawale
  • 1,216
  • 9
  • 19
0

You are missing the Closing slash of the context tag. Also forward slashes are preferable and work as well on Windows.

<Context docBase="E:/images/" path="/images" />
DrHopfen
  • 752
  • 3
  • 13