Technically speaking, Servlet is a Java object that is based on Servlet framework and extends the functionality of a web server basically being responsible for creating dynamic contents. A Servlet is mapped to a corresponding URL and its life-cycle is managed by the container.  The URL is the address to which a client send HTTP request. Servlet technology is available and running on all major web servers and app servers. Since it is based on Java, it is platform and server independent.

Consider the code example given below. So this is an example of very simple Servlet code.  As you can see, a Servlet is a Java code.  Here a Servlet is named as HelloServlet and it extends a Java interface called HttpServlet.  Inside the code, there are a few predefined methods you want to override, for example, here doGet() method gets called with HttpServletRequest object and HttpServletResponse object as parameters.  The HttpServletRequest is a java object that is created by the container and captures  an incoming HTTP request in an object form.

Now in this example, the handling of the request is very simple – just send back “Hello World!” message. That is, the browser, once it receives the HTTP response message that contains the “Hello World” message, will display “Hello World!” message on the screen as a result of accessing this Servlet.

If you understand the basics and wanted to learn more about Servlets, Please click the following link to Download the resources. [Download]

Tagged with: JAVASource Code

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Related News Feeds

Set your Twitter account name in your settings to use the TwitterBar Section.