I'm migrating an old project from a web.xml
approach to a complete Java-style Servlet 3.0 configuration.
But I can't understand how to translate part of the XML configuration in Java code. In particular the next snippet:
<jsp-config>
<taglib>
<taglib-uri>....</taglib-uri>
<taglib-location>....</taglib-location>
</taglib>
</jsp-config>
Any hint would be welcome!
As a secondary, more academic, question: do Servlet 3.0 API offer a full coverage of what you could do with XML, or not?
Stefano,
Since JSP 2.0, there is no need in put <taglib>
tag in web.xml. From Head First Servlets and JSP book:
The Container automatically builds a map between TLD files and names, so that when a JSP invokes a tag, the Container knows exactly where to find the TLD that describes the tag. How? By looking through a specific set of locations where TLDs are allowed to live. When you deploy a web app, as long as you put the TLD in a place the Container will search, the Container will find the TLD and build a map for that tag library.
So, all you have to do is to have a TLD file with the correct URI.
Places to put your TLD file:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.