Reputation: 9060
Sorry about the vague title but I have a servlet with the following mapping in web.xml
<servlet>
<servlet-name>SomeServlet</servlet-name>
<servlet-class>SomePackage.SomeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SomeServlet</servlet-name>
<url-pattern>/servlet/SomeServlet</url-pattern>
</servlet-mapping>
that opens a html file in a different folder and writes to Response. As a result, the images in that html try to load /servlet/images/someimage.png
instead of /images/someimage.png
I know that the image reference in the html is relative and hence it trying to go from the servlet path but I can't change the html page or the servlet code. Is there any why to fix this from the configuration files?
Thanks
Upvotes: 1
Views: 2339
Reputation: 1474
In You HTML file use the context path..
<img src ="/CONTEXT/images/someimage.png"/>
e.g
<img src ="/StackOverOverflow/images/someimage.png"/>
Sorry I didn't notice that you can't change the HTML.
How about creating a filter which will filter out the images and will forward the call to the servlet if it matches your servlet path? Did you try this?
Upvotes: 0
Reputation: 691635
Map the servlet to /SomeServlet
.
Or create a servlet mapped to /servlet/images/*.jpg
that forwards to /images/Xxx.jpg
, where Xxx
is what matched the wildcard.
What kind of environment are you working in, where you can't change anything?
Upvotes: 2