Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Java Servlet?

I read many articles to understand Java servlet but I did not succeed.

Can you please give brief introduction of Java servlets (in easy language). What is a servlet? What are the advantages?

I can't understand the difference between server-side programming languages (PHP, ASP) and servlets.

like image 900
hardik Avatar asked Aug 27 '11 09:08

hardik


People also ask

What is servlet used for in Java?

A servlet is a Java programming language class that is used to extend the capabilities of servers that host applications accessed by means of a request-response programming model. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by web servers.

Is Java Servlet a framework?

The Servlet and JSP are incredibly simple ways to handle an incoming request, and to develop HTML that gets displayed inside a client's web browser, respectively. All the existing Java-based web frameworks simply build on top of the Servlet and JSP API.

What is servlet and JSP?

Java™ servlets and Java server pages (JSPs) are Java programs that run on a Java application server and extend the capabilities of the Web server. Java servlets are Java classes that are designed to respond to HTTP requests in the context of a Web application.

What is Java Servlet and Tomcat?

Apache Tomcat is a long-lived, open source Java servlet container that implements core Java enterprise (now Jakarta EE) specifications, including the Jakarta Servlet, Jakarta Server Pages, and Jakarta WebSocket specs.


1 Answers

A servlet is simply a class which responds to a particular type of network request - most commonly an HTTP request. Basically servlets are usually used to implement web applications - but there are also various frameworks which operate on top of servlets (e.g. Struts) to give a higher-level abstraction than the "here's an HTTP request, write to this HTTP response" level which servlets provide.

Servlets run in a servlet container which handles the networking side (e.g. parsing an HTTP request, connection handling etc). One of the best-known open source servlet containers is Tomcat.

like image 100
Jon Skeet Avatar answered Oct 16 '22 18:10

Jon Skeet