Remap image requests in a web application (tomcat) with spring for an absolute path?

You can create a new context with docBase referencing to your folder ( root/var/img ) It should look like this.

You can create a new context with docBase referencing to your folder (/root/var/img) It should look like this: Refer to Tomcat context configuration documentation for more details (e.g. , for Tomcat 6: Apache Tomcat Configuration Reference: The Context Container). Introduction to this document lists possible places where context elements can be defined. EDIT As I mentioned in comments, Spring-specific way to do this without creating any new context seems to be using RedirectView (link to Spring v2.5 JavaDoc).

According to JavaDoc: "View that redirects to an absolute, context relative, or current request relative URL, by default exposing all model attributes as HTTP query parameters. " EDIT2 It seems I've misunderstood RedirectView purpose, which is a good old URL redirection. Thus, answer by @Jens should be more appropriate (+1).

I still wonder if there's an existing standard solution in Spring (what I originally thought RedirectView would do..) It's not like there's much code to write, but still :) EDIT3 After reading more on this topic, I found out that is able to do this (i.e. , mapping resource using not only relative path, or classpath), you just need to correctly configure location using file: prefix . In fact, there's already answer on SO that explains exactly what you need to do: Spring : serving static resources outside context root.

Thanks for the tip, but if possible I would prefer to not create a new context, a servlet based solution would be better for me... – Gnappuraz Aug 14 at 14:23 @Gnappuraz Ahh, I see. What about Spring's RedirectView (link to v2.5 JavaDoc)? JavaDoc states: "View that redirects to an absolute, context relative, or current request relative URL, by default exposing all model attributes as HTTP query parameters." – Arturs Licis Aug 14 at 14:28 the only standard solution I found is the tag, that allow this remap but only for relatives paths.

– Gnappuraz Aug 15 at 7:42 @Gnappuraz: I've read more on , and updated my answer. – Arturs Licis Aug 15 at 8:55 tnx a lot =) i've resolved – Gnappuraz Aug 16 at 7:53.

Not sure if I am getting that right but I think the common way to do that is to set up a controller which is mapped on the requests to /images/: @RequestMapping(value ="/images/") public void fetchImage(@RequestParam String id, HttpServletResponse response) Then the controller can load the requested image from a configured directory like "/root/var/img" and write it the the OutputStream of the response. E. G: org.apache.commons.io.IOUtils.

Copy(fileInputStram, response.getOutputStream()) In addition you have to set the correct mime type etc. In the response. Jens.

Yes, i'm just trying to do something similar, with this controller @RequestMapping(value="/images/") public void fetchImage(@RequestParam String id, OutputStream output) – Gnappuraz Aug 15 at 7:47.

Not sure if I am getting that right but I think the common way to do that is to set up a controller which is mapped on the requests to /images.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions