Hi All, I have embedded the jspwiki project within my own webapp, to provide a help engine. The jspwiki project provides java classes (in a jarfile) plus some .jsp files and assorted resource-files (images, scripts, etc). Currently I put all the java classes as a jarfile in my classpath (ok), and also unpack the jsp and resource files into my webapp's content directory (ugly).
I would like to serve all of the jspwiki jsp files directly out of a jarfile, so my app's source does not get cluttered. So for example, any request to "/myapp/help/foo/bar.jsp" should instead resolve to "jspwiki-jsps.jar!/foo/bar.jsp". Ideally, requests for js, images, etc. should also be served from the jarfile. This seems a not-too-unusual thing to do: building a webapp out of other webapps that provide jsps (not just classes). I can't see anything in the FAQs or standard Tomcat docs, and searching online turned up nothing. I did find one email thread here: http://www.nabble.com/JSPs-in-JAR-to9589338.html#a9589338 but this isn't quite what I'm wanting. I have noticed that the server.xml can be configured to point to a custom DirContext class, like this: <Context ....> <Resources className="my.custom.dircontext.impl"/> </Context> So it seems that I could write a custom DirContext that first tries standard processing, then if nothing is found and the requested uri starts with "/help/" then look in the classpath (or specific jars directly). The JspServlet calls ServletContext.getResource(uri) to get the source of the jsp file, and that delegates to StandardContext.getResources, which delegates to its DirContext object, which is what is configurable as shown above. Therefore this does seem a promising line to take. It's not trivial, though. In particular, the DirContext interface is a large one to implement, and the Resource interface also seems a bit tricky. It also seems to me via some experiments that the specified class must be in a jar at the "container" level, not within the webapp, which is more intrusive than I would like. Am I being stupid here, and missing something obvious? Is there an easier way to achieve what I'm trying to do? Or has someone already done this, and is willing to share some code? Note that I'm not expecting to write <%include%> tags in my jsps that reference the "imported" code (in fact, my app is JSF with Facelets, not jsp at all). And I don't care about jsp "hot reload". But I do want the result to be just *one* webapp (one ServletContext); redirecting to another webapp or dynamically fetching pages from another webapp is not what I'm aiming for. Any suggestions are very welcome.. Thanks, Simon --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org