Wednesday, September 28, 2005

What is a Servlet? What is a web component?

From Spec:

A servlet is a Java technology-based Web component, managed by a container, that generates dynamic content. Like other Java technology-based components,servlets are platform-independent Java classes that are compiled to platform-neutral byte code that can be loaded dynamically into and run by a Java technology-enabled Web server.

First, when most people refer to a servlet, they actually mean an object of class HttpServlet. When I refer to a servlet, think "HttpServlet".

A servlet is an object who has the ability to communicate with a web browser. It receives requests from a browser. These requests can ask for a web page, or they can send data that a user entered on a web page. To code one of these, all you have to do is declare a class that extends HttpServlet, override the doGet and/or doPost method. It is in these methods that you add your own code(Business Logic) to do whatever you want. To send a webpage back to the browser, all you need to do is write HTML code as Strings inside println statements.

A web component is either a servlet or a JSP page

0 Comments:

Post a Comment

<< Home