Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to share the same MVC between external Jars and a War in Servlet 3.0 environment?

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?

like image 612
Clement Martino Avatar asked Nov 30 '12 23:11

Clement Martino


1 Answers

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.

like image 176
Christian Beutenmueller Avatar answered Sep 27 '22 18:09

Christian Beutenmueller