-1

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)?

VH-NZZ
  • 5,248
  • 4
  • 31
  • 47
mahesh
  • 47
  • 1
  • 5
  • I am sorry but they way you wrote the question is quite hard to understand .. – Maciej Cygan May 08 '14 at 09:40
  • "Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Sun Microsystems" What does above statement mean? – mahesh May 08 '14 at 09:46
  • Tomcat is a servlet container. Servlets run in servlet containers. JSPs are servlets. If that doesn't answer your question, nothing will. – user207421 May 08 '14 at 09:54
  • yeah i got it, but the above mentioned statement i couldn't get it. What are the specification does tomcat implement? – mahesh May 08 '14 at 10:01

4 Answers4

4

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.

Community
  • 1
  • 1
VH-NZZ
  • 5,248
  • 4
  • 31
  • 47
  • @mahesh I _strongly_ encourage you to download one specification and skim through it. It will most probably answer 99%+ questions you'll ever have on the technology. – VH-NZZ May 08 '14 at 11:26
  • 1
    @mahesh Also, I think that the downvotes are a little harsh: I'd bet that a majority of so-called programmers who added Java on their resume have a no clear understanding thereof. – VH-NZZ May 08 '14 at 11:28
  • being beginner I did not understand and might unable to post it properly, but thank you soooo much for your support and encouragement. – mahesh May 08 '14 at 11:52
1

You can run Servlet in a container that is capable of runing Servlets. Such containers include

Tomcat
GlassFish
WebSphere
Jetty etc.

.

JSP - which stands for Java Server Page - is more of a web page, that can include HTML and XML and other technologies (or languages should i say). JSP is similar to PHP but uses Java language.

"Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Sun Microsystems" <- this means that Tomcat can run both - in essence

"...specifications from Sun Microsystems (Or call it Oracle as Sun does not exist anymore)", What this means is that Tomcat is capable of implementing language specifications set by Sun ( Oracle now ).

The specification you are after are JSR-000315 Java Servlet and JSR-00245 Java Server Page

So it provides a "pure Java" HTTP web server environment for Java code to run in.

Note : Servlets can be generated automatically from Java Server Pages (JSP) by the JavaServer Pages compiler. The difference between servlets and JSP is that servlets typically embed HTML inside Java code, while JSPs embed Java code in HTML.

I mean there is not much more to it ...

Community
  • 1
  • 1
Maciej Cygan
  • 5,351
  • 5
  • 38
  • 72
  • thnks for ur reply Maciej Cygan, I'm getting remaining things but the only statement confusing me. what specification does it implement? – mahesh May 08 '14 at 10:03
0

You should give a bit more context, so that people have a chance to help you.

Apache Tomcat is a java servlet engine and thus implements among others the specification of java servlets. It means, it is a container for java applications bundled in a war file, containing servlets.

Alexander Rühl
  • 6,769
  • 9
  • 53
  • 96
0

JavaEE is all about specifications basically set of interfaces & abstract classes, all these specifications are under javax package.

Implementation provider use these specification and provide implementations.

Here is an example of tomcat server, using servlet specifications. https://github.com/apache/tomcat/tree/3e5ce3108e2684bc25013d9a84a7966a6dcd6e14/java/javax

Our code is not dependent on any of the implementation of tomcat, basically bridge pattern used where, application access the implementation through the interface which will remain same.

Amar T
  • 359
  • 1
  • 7