Search code examples
javajsptomcatservletsspecifications

Does Tomcat implement or run the Java Servlet and the JavaServer Pages (JSP) specifications?


I'm learning about Apache Tomcat and I didn't understand the term implementation from the below line. I was thinking Tomcat runs Java Servlet and the JavaServer Pages (JSP).

Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Sun Microsystems

Does Tomcat implement or run the Java Servlet and the JavaServer Pages (JSP)?


Solution

  • JavaServerPages (JSR 245) and Java Servlet (JSR 315) are Java specifications.

    They are just that: a set of guidelines that are joined in a document full of words about what they are, how they should behave, etc..

    Now here's the answer to your question: Vendors take those specifications to make libraries or products that implement these specifications, thus becoming an implementation thereof. This much in the way you'd implement an interface.

    Therefore

    Tomcat implements Java Servlet and the JSP specifications

    is the right way to say describe that. Now Tomcat has its own HttpServlet implementation but you needn't worry about that because your classes just extend it.

    Of course, your own servlets and JSPs will run on Tomcat but they'll extend their own implementations. Similarly they'll run on, eg., Jetty where they'll be extending different implementations of the classes.

    Note that those classes (HttpServlet, ...) are in packages that start with javax. and not java.. The difference is key and I suggest that you have a look at: javax vs java package

    Another widely popular example is JPA: https://jcp.org/en/jsr/detail?id=338 and its many implementations like Hibernate, EclipseLink, OpenJPA, DataNucleus, etc.