Servlet

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

Java web Application

what is servlet : servlet is a java class that runs in a web server.It cannot be
able to run
in normal jvm,So it is not a POJO class. It accepts request from html file,
processess that request and finally
forward the response to the client's web browser through html file.

All servlert/Java web Technical classes & interfaces are present in javaX.servlet,
javax.servlet.http &
javax.servlet.jsp packages.

1.Servlet interface
2.GenericServlet class
3.HttpServlet class
4.ServletRequest interface
5.ServletResponse intierface
6.HttpServletRequest
7.HttpServletResponse

Every user defined Servlet must extend GenericServlet/HttpServlet.


GenericServlet implements the Servlet interface. It is a abstract class.It inherits
the Object class.
It is the base class of all Servlet.

HttpServlet is the child class of the GenericServlet.It is also an abstract


class.It accmodates
the http technical features like get/post, cookies, session variables etc.

ServletRequest interface accepts the web client's request and forwards to the
servlet class.
It is child interface of ServletRequest.
ServletResponse interface interface forwards the servlet's output to the client's
browser.
HttpServletResponse interface forwards the servlet's output to the http client's
browser.

Apache tomcat is a web Server.It can execute java classes.its default port number
is 8080.

Writer --> Response ---> Client Browser


----------------------------
Web Server

What is Jsp?
Java Server Pages
It is a java based web development technology which is alike a html page,Here same
manner css,bootstrap &
javascript codes can be attached like html page. It supports 1.all html tags 2. all
css,bootstrap scripting codes,
3.own tags (developed based on jav applications,perform to process the data,that's
why they called themselves an action tag).
4. java programming code.So it is an extension of html page.In industry jsp pages
are used for view purpose i.e accept input from users
& display processed output.
However usage of java code inside jsp page is considered as ideal practice in
industry.
Actually jsp is a disguised servlet.
All jsp files are converted into a servlet which extends HttpJspBase class (It is a
drived class of HttpServlet).

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"


pageEncoding="ISO-8859-1"%> --> Page directive.
it directs a jsp page to convert into a java class

this jsp is converted to java by the jasperEngine present in jasper Application


which is auto invoked.

Java Bean class ---> Model


Jsp page --->
controller

You might also like