We are trying to build up a modular system where jars contain application contexts and jsps along with the classes. Different URIs are located in different jars.
For example lets say we have a request for /monkey/home.html and another for /elephant/home.html. I need monkey to go to WEB-INF/lib/monkey-1.1.jar!/WEB-INF/jsp/monkey/home.jsp and elephant to go to WEB-INF/lib/elephant-1.1.jar!/WEB-INF/jsp/monkey/home.jsp. Then there are other's that are in the main webapps web-inf/jsp such as a request for simply home.html should be found in web-inf/jsp/home.jsp.
Any ideas on how to implement a org.springframework.web.servlet.ViewResolver to be able to find the jsp in the jar? I started something, but its not working:
<bean id="viewResolver" class="com.retrieve.commons.viewResolver.JarViewResolver">
<property name="cache" value="false" />
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
<entry key="monkey" value="animals-monkey-5.2.jar"/>
<entry key="elephant" value="animals-elephant-5.2.jar"/>
public class JarViewResolver
private String requested;
private Map<String, String> locations = new HashMap<String, String>();
public void setLocations(Map<String, String> locations)
this.locations = locations;
protected String getPrefix()
Set<Map.Entry<String, String>> entries = locations.entrySet();
for (Map.Entry entry : entries)
return "/WEB-INF/lib/" + entry.getValue().toString() + "!/WEB-INF/jsp/";
protected AbstractUrlBasedView buildView(String s)
requested = s; // /elephant/Home
Lets assume the file is indeed in that location, in that jar, and in that web-inf jsp directory. How can I pull a resource from the jar?
HTTP Status 404 -The requested resource (/context/WEB-INF/lib/animal-monkey-5.2.jar!/WEB-INF/jsp/monkey/Home.jsp) is not available.