Skip to content
Advertisement

Including JSTL implementation jar only

Following this answer, below is a simple JSP demo that includes only JSTL implementation jar(javax.servlet.jsp.jstl-1.2.1.jar), but not JSTL API jar(javax.servlet.jsp.jstl-api-1.2.1.jar),

enter image description here


My understanding is, JSTL implementation jar holds both API(mostly Java interfaces) and it’s implementation. This is the reason test.jsp got compiled and executed successfully.

Further, same approach would work with servlets using API implementation jar provided by Tomcat container without using API(servlet-api.jar).


Is this the right understanding?

Advertisement

Answer

Api contains only interfaces you need to compile your code. The implementation could be in different library.

Tomcat and any other Java web servers provide implementation at runtime, so you don’t need to package implemented classed and carry on them with your app.

You could see in the logs if implementation is already loaded if you deploy your application that contains classes impl.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement