I'm still a bit new to using custom tag libraries and I'm running into a problem that I hope is easy to solve. I have a web application that I've added custom tags to and when deployed to a Tomcat 8 server, the custom tag library is found and is useable in JSP pages within that web application but not the default context.
Part of needing to use a custom tag library is that I'm rewriting a lot of old code to use JSPs and the server that I'll eventually be deploying the application to is going to be customer facing and I don't want to have things like
for users because this is very old and they are expecting :
to be the home page. I've seen lots of ways to solve this but so far the easiest and fastest is to point the default context to a directory in the web application to serve as the docroot. Within the server.xml of the server I've added the line
<Context path="" docBase="NewWebApp/web_resources" />
Here's the issue:
If I go to https://example.com/NewWebApp/web_resources/index.jsp
, it finds the taglib that is in the WEB-INF directory and the tag works.
If I go to https://example.com/
it finds the correct index.jsp file like it should but I get an error similar to:
Unable to find taglib [a] for URI: [CustomTagLib]
I've been trying to find more techincal documentation on exactly how the taglibs are loaded into a context and I guess I had assumed that any context would automatically include the entire webapplication that it uses as a docBase but that obviously isn't true. I just haven't found exactly how to expose a taglib from one application to make it visible server wide or I'm not understanding enough about how contexts are populated because to me it seems like this is the issue. The taglib I have in the NewWebApp context isn't visible to the default context. Is there a way to make it visible? If I pack the custom tag into a jar and put it in the NewWebApp/lib directory will the default context be able to see it? Or should I just forget this and focus on using URL rewriting instead to make the URLs presented to the user pretty?