Professional Documents
Culture Documents
Why jsp?
In early days web applications are static and they are created with the help of one
or more html pages.
Late there is requirement came for dynamic web applications and to develop
dynamic pages a first server side web technology was released with the name CGI
technology (common gateway interface)
With CGI technology there are two major problems identified as it increases burden
on server and it is not a secure technology
Later sun Microsystems released servlet technology for creating dynamic web
applications.
Servlet technology provides less burden and it is secure technology but developer
should write a very large amount of java code for creating the application logics
Microsoft introduced a technology called ASP (Active server pages) with a set of
predefined tags and a small amount of VB script code, for developing dynamic web
applications
Industry developers attracted for ASP due to less amount of code for dev eloping
web applications
Again to migrate developers from Microsoft technology to Sun Microsystems , sun
people introduced a second server side technology for creating web applications
with name JSP
Definition:- Java Server Pages (JSP) is a Java technology that allows software
developers to generate the dynamic web content
Servlets
Jsp
4
5
Jsp Translation:
each jsp page will be translated into a servlet in server
A jsp execution in server has two phases
1. translation phase
2.execution phase
in translation pahase, first a jsp page iwll be converted to equivalent servlet and
then a servlet will be compiled.
in execution phase. object is created for a servlet then it is initialized then finally
service() is executed
in translation phase a jsp container(we container) will uses a page compiler for
converting a jsp page into a servlet then a java compiler for converting .class file
.jsp.java.class
A Jsp container will execute translation phase then followed by execution phase,
when first request is sent to jsp page and when a jsp page modified. In other
request only service is executed
When a first request arrived to a JSP
Jsp
life
cycle methods:
Jsp life cycle methods looks like servlet life cycle methods only
Life cycle methods of jsp page are given in javax.servlet.jsp.HttpJspPage interface.
HttpJspPage extends javax.servlet.jsp.JspPage interface.
In JspPage interface, 3 life cycle methods of jsp are given
1.jspInit()
2.jspDestroy()
In HttpJspPage interface , one more life cycle method of jsp is given called
_jspService().
Life cycle methods of jsp page are:
1.jspInit()
2.jspDestroy()
3._jspService(request,response).
When a jsp page is translated into an equivalent servlet class, that servlet class
indirectly implements HttpJspPage interface
At the time of translating a jsp page, a container extends the servlet calss from a
super class. That super class extends HttpServlet and implements HttpJspPage
interface
Ex:
In case of tomcat container extends internal servlet class of jsp page from a super
class HttpJspBase and it extends HttpServlet and implements HttpJspPage interface