简体   繁体   中英

Why does JSP need tomcat or any other extra server for that matter?

I recently started learning java and JSP. To run JSP I was informed that I need to download apache tomcat. I did that and configured it to eclipse and got results. What exactly is this apache tomcat and why does JSP need it?

It's a servlet or web container .

What does it do ? It directs incoming HTTP requests to one of many servlet applications it manages, and looks after the separation of those apps, threading/management of requests, and the network I/O.

If you didn't have this, you'd have to write the networking code, the HTTP protocol code, threading for the incoming requests, sandboxing of different applications (via classloaders) and handling of servlets' lifecycles (initialisation/destruction etc.)

With a servlet container, you can concentrate on the incoming HTTP requests that you're provided and providing suitable output as an HTTP response, and not worry about any of the above.

The JSPs you're writing are a specialised form of servlet.

Apache Tomcat is a servlet container
It interprets Servlets on which JSP files are based
For your Java EE applications you can use a servlet container like Tomcat or an application server like JBoss which can manage EJBs this post describe the difference between servlet container and application server

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM