8

I understand that Servlet 3.0's enhancements have made it possible to display a .jsp from a .jar, based on Can I serve JSPs from inside a JAR in lib, or is there a workaround?

However, I don't seem to be able to connect my View (jsp in jar WEB-INF/lib Tomcat 7 and classic spring MVC context configuration in a War) with the Model and the Controller of my Web App.

Is there a good way to share the dispatcher Servlet, or perhaps create a CustomViewResolver which could scan .jsps included in external JARs, and actually plug my jar into a unique spring context?

Community
  • 1
  • 1
Clement Martino
  • 463
  • 3
  • 17
  • 1
    I think this answer could also apply to JSPs : http://stackoverflow.com/questions/6104498/jee6-packaging-jsf-facelets-xhtml-and-managedbeans-as-jar – Alexandre Lavoie Dec 01 '12 at 01:08
  • what's the problem exactly with connecting Servlet3 jsps and controller? – xeye Dec 03 '12 at 11:34
  • the problem is the way to connect a classic controller defined in a classic web-app (WAR) to views (jsp) included only in external jar ! – Clement Martino Dec 03 '12 at 16:53

1 Answers1

1

With JSP you have the problem of compilation. So you at least need to precompile them, to have them included. Then it should be possible, since after compilation a JSP is basically a Servlet.

If you would use another view technology like Velocity, Freemarker or JSF based on Facelets, you can very easily use a classpath based ViewResolver.