SlideShare una empresa de Scribd logo
1 de 16
Submitted By:
Dipen Modi (160110107030)
NarsinganiAmisha (160110107031)
Vivek Nathani (160110107032)
Guided By:
Dr. Hetal Gaudani
 Java Server Pages(JSP) is a technology for developing portable java web applications
that runs on a java web server.
 Main motivation behind developing JSP was to develop a technology so that a non-java
programmer or a person with little knowledge of java could write web applications for
java platform.
 Initially JSP was developed to replace servlet but now common practice is to use servlet
and JSP together using MVC(model-view-controller) pattern.
 JSP allows developer to write html (static content),JSP action tags and java (dynamic
content) code in the same page.
 JSPS are compiled into java servlets by a JSP compiler, thus internally JSP page is
converted into servlet, it is must to understand java servlet technology thoroughly for
becoming a good JSP programmer.
 Java Server Pages (JSP) supports dynamic content which helps developers insert
java code in HTML pages by making use of special JSP tags, most of which start
with <% and end with %>.
 JSP enables you to separate the dynamic content of a web page from its
presentation.
 It caters to different types of developers:
 Web designers, who are responsible for the graphical design of the page.
 Java developers, who write the code to generate dynamic content.
The JSP pages follows these phases:
 Translation of JSP page
 Compilation of JSP page
 Class loading (class file is loaded by the class loader)
 Instantiation (object of the generated servlet is created).
 Initialization ( jspinit() method is invoked by the container).
 Request processing ( _jspservice() method is invoked by the container).
 Destroy ( jspdestroy() method is invoked by the container).
1. Translation of JSPto Servlet code
 WebContainertranslates JSPcodeinto aservletsource(.java)file.
 Thisisthe firststepin its tediousmultiple phaselife cycle.
 Inthetranslation phase,thecontainervalidatesthe syntacticcorrectnessof theJSPpages and tagfiles.
 The container interprets the standard directives and actions, and the custom actions referencing tag
libraries usedin thepage.
2. Compilation ofServlet to bytecode
 The JSPengine compiles the servlet into an executable class and forwards the original request to a servlet
engine.
 The translation of a JSPsource page into its implementation class can happen at any time between initial
deployment of the JSPpage into the JSPcontainer and the receipt and processing of a client request for
the targetJSPpage.
3. LoadingServlet class
• Thejavaservlet classthat wascompiledfrom the JSPsourceisloaded into thecontainer.
4. Creatingservletinstance
• In this executionphasethe container managesoneor more instances of this classin responseto requests
and otherevents.
5. Initialization bycallingjspInit() method
 WhenacontainerloadsaJSPit invokesthejspInit()methodbefore servicinganyrequests. If youneedto
performJSP-specificinitialization,override the jspInit().
 Typically, initialization is performed only once and aswith the servlet init method, you generally initialize
databaseconnections,openfiles,andcreatelookuptablesinthejspInit method.
public void jspInit()
{
//initializing the code
}
6.RequestProcessingbycalling_jspService() method
 Thisphaseof the JSPlife cyclerepresentsall interactions with requests until the JSPis destroyed.
 Whenever abrowser requests aJSPandthe pagehasbeen loadedandinitialized, the JSPengine
invokesthe _jspService()method in theJSP.
 The_jspService()method takesanHttpServletRequest andanHttpServletResponseasits
parameters .
• void _jspService(HttpServletRequest request,
• HttpServletResponse response) {
// Service handling code...
}
 The_jspService()method of aJSPisinvoked onrequest basis.Thisisresponsiblefor generating the
responsefor thatrequest.
7. DestroyingbycallingjspDestroy() method
 Thedestruction phaseof the JSPlife cyclerepresentswhen aJSPisbeingremoved from usebya
container.
 ThejspDestroy()method isthe JSPequivalentof the destroy method forservlets.
 Override jspDestroy(),whenyouneedto perform anycleanup,suchasreleasingdatabase
connectionsor closingopenfiles.
public void jspDestroy()
{
//Your cleanup code goes here.
}
 Whenthecallto destroymethod ismadethen,theservletisreadyfor agarbagecollection
 Thisisthe endof the JSPlifecycle.
The following steps explain how the web server creates the web page using JSP:
 As with a normal page, browser sends an HTTP request to the web server.
 The web server recognizes that the HTTP request is for a JSP page and forwards it to a JSP engine.This
is done by using the URL or JSP page which ends with .jsp instead of .html.
 The JSP engine loads the JSP page from disk and converts it into a servlet content.This conversion is
very simple in which all template text is converted to println( ) statements and all JSP elements are
converted to Java code that implements the corresponding dynamic behavior of the page.
 The JSP engine compiles the servlet into an executable class and forwards the original request to a
servlet engine.
 A part of the web server called the servlet engine loads the Servlet class and executes it. During
execution, the servlet produces an output in HTML format, which the servlet engine passes to the web
server inside an HTTP response.
 The web server forwards the HTTP response to your browser in terms of static HTML content.
 Finally web browser handles the dynamically generated HTML page inside the HTTP response exactly
as if it were a static page.
 Servlets provide a way to generate dynamic documents that is
both easier to write and faster to run.
 provide all the powerfull features of JAVA, such as Exception
handling and garbage collection.
 Servlet enables easy portability across Web Servers.
 Servlet can communicate with different servlet and servers.
 Since all web applications are stateless protocol, servlet uses
its own API to maintain session
 Designing in servlet is difficult and slows down the
application.
 Writing complex business logic makes the application difficult
to understand.
 You need a Java Runtime Environment on the server to run
servlets. CGI is a completely language independent protocol,
so you can write CGIs in whatever languages you have
available (including Java if you want to).
 Allows tag based programming. So extensive java knowledge is not
required.
 Use nine implicit objects, which we can use directly in our JSP program
 Modification done in JSP program will be recognized by underlying server
automatically without reloading of web application.
 Allows us to use separate presentation logic (html code) from Java
code(business logic).
 Increases readability of code because of tags.
 Gives built-in JSP tags and also allows to develop custom JSP tags and to
use third party supplied tags
 Takes care of exception handling
 Suitable for both java and non java programmer
 Debugging JSP programs is still a major challenge.You have to
remember that a jsp page will be first converted to a .java file and
then compiled.Thus, any errors will be pointing to line numbers in
the converted .java file and not the .jsp page.For example an error
in the first line of .jsp page may be shown on the 20th line of the
.java file.Tracing back can be somewhat tricky.
 Database connectivity is not as easy as it should be. Most of the
servlet engine vendors do not support connection pooling
natively, as of this day. Consequently, one has to write a lot of
custom code to do the job.
 It is not an easy task to choose the appropriate servlet engine.
 There are numerous syntax related issues with JSP programming.
Servlet JSP
Servlet is faster than jsp JSP is slower than Servlet because it first
translate into java code then compile.
In Servlet, if we modify the code then we need
recompilation, reloading, restarting the server.
It means it is time consuming process.
In JSP, if we do any modifications then just we
need to click on refresh button and
recompilation, reloading, restart the server is
not required.
Servlet is a java code. JSP is tag based approach.
In Servlet, there is no such method for running
JavaScript at client side.
In JSP, we can use the client side validations
using running the JavaScript at client side.
To run a Servlet you have to make an entry of
Servlet mapping into the deployment
descriptor file i.e. web.xml file externally.
For running a JSP there is no need to make an
entry of Servlet mapping into the web.xml file
externally, you may or not make an entry for
JSP file as welcome file list.
Coding of Servlet is harden than jsp. Coding of jsp is easier than Servlet because it is
tag based.
Servlet JSP
In MVC pattern, Servlet plays a controller role. In MVC pattern, JSP is used for showing output
data i.e. in MVC it is a view.
Servlet accept all protocol request. JSP will accept only http protocol request.
In Servlet, service() method need to override. In JSP no need to override service() method.
In Servlet, by default session management is
not enabled we need to enable explicitly.
In JSP, session management is automatically
enabled.
In Servlet we do not have implicit object. It
means if we want to use an object then we
need to get object explicitly from the servlet.
In JSP, we have implicit object support.
In Servlet, we need to implement business
logic, presentation logic combined.
In JSP, we can separate the business logic from
the presentation logic by uses java Bean
technology.
In Servlet, all package must be imported on top
of the servlet.
In JSP, package imported anywhere top, middle
and bottom.

Más contenido relacionado

La actualidad más candente (20)

Jsp
JspJsp
Jsp
 
Jsp chapter 1
Jsp chapter 1Jsp chapter 1
Jsp chapter 1
 
Jsp
JspJsp
Jsp
 
JSP Directives
JSP DirectivesJSP Directives
JSP Directives
 
Jsp
JspJsp
Jsp
 
Jsp (java server page)
Jsp (java server page)Jsp (java server page)
Jsp (java server page)
 
J2EE jsp_01
J2EE jsp_01J2EE jsp_01
J2EE jsp_01
 
Implicit objects advance Java
Implicit objects advance JavaImplicit objects advance Java
Implicit objects advance Java
 
Jsp elements
Jsp elementsJsp elements
Jsp elements
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
 
JSP - Java Server Page
JSP - Java Server PageJSP - Java Server Page
JSP - Java Server Page
 
Servlet and jsp interview questions
Servlet and jsp interview questionsServlet and jsp interview questions
Servlet and jsp interview questions
 
Implicit object.pptx
Implicit object.pptxImplicit object.pptx
Implicit object.pptx
 
Jsp element
Jsp elementJsp element
Jsp element
 
Introduction to JSP
Introduction to JSPIntroduction to JSP
Introduction to JSP
 
Csajsp Chapter10
Csajsp Chapter10Csajsp Chapter10
Csajsp Chapter10
 
Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Jsp lecture
Jsp lectureJsp lecture
Jsp lecture
 
Jsp
JspJsp
Jsp
 

Similar a JSP overview

The Java Server Page in Java Concept.pptx
The Java Server Page in Java Concept.pptxThe Java Server Page in Java Concept.pptx
The Java Server Page in Java Concept.pptxKavitha713564
 
Online grocery store
Online grocery storeOnline grocery store
Online grocery storeKavita Sharma
 
Servlets and jsp pages best practices
Servlets and jsp pages best practicesServlets and jsp pages best practices
Servlets and jsp pages best practicesejjavies
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsKaml Sah
 
Jsp interview questions by java training center
Jsp interview questions by java training centerJsp interview questions by java training center
Jsp interview questions by java training centerMaheshit Jtc
 
Jsp and Servlets
Jsp and ServletsJsp and Servlets
Jsp and ServletsRaghu nath
 
Enterprise java unit-3_chapter-1-jsp
Enterprise  java unit-3_chapter-1-jspEnterprise  java unit-3_chapter-1-jsp
Enterprise java unit-3_chapter-1-jspsandeep54552
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESYoga Raja
 
JavaScript, often abbreviated as JS, is a programming language and core techn...
JavaScript, often abbreviated as JS, is a programming language and core techn...JavaScript, often abbreviated as JS, is a programming language and core techn...
JavaScript, often abbreviated as JS, is a programming language and core techn...MathivananP4
 

Similar a JSP overview (20)

Jsp in Servlet by Rj
Jsp in Servlet by RjJsp in Servlet by Rj
Jsp in Servlet by Rj
 
Java server pages
Java server pagesJava server pages
Java server pages
 
Unit 4 web technology uptu
Unit 4 web technology uptuUnit 4 web technology uptu
Unit 4 web technology uptu
 
Unit 4 1 web technology uptu
Unit 4 1 web technology uptuUnit 4 1 web technology uptu
Unit 4 1 web technology uptu
 
Jsp
JspJsp
Jsp
 
The Java Server Page in Java Concept.pptx
The Java Server Page in Java Concept.pptxThe Java Server Page in Java Concept.pptx
The Java Server Page in Java Concept.pptx
 
Java JSP.pptx
Java JSP.pptxJava JSP.pptx
Java JSP.pptx
 
Jsp
JspJsp
Jsp
 
Jsp Introduction Tutorial
Jsp Introduction TutorialJsp Introduction Tutorial
Jsp Introduction Tutorial
 
Online grocery store
Online grocery storeOnline grocery store
Online grocery store
 
Servlets and jsp pages best practices
Servlets and jsp pages best practicesServlets and jsp pages best practices
Servlets and jsp pages best practices
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - Components
 
Jsp interview questions by java training center
Jsp interview questions by java training centerJsp interview questions by java training center
Jsp interview questions by java training center
 
Jsp and Servlets
Jsp and ServletsJsp and Servlets
Jsp and Servlets
 
Spatial approximate string search Doc
Spatial approximate string search DocSpatial approximate string search Doc
Spatial approximate string search Doc
 
Enterprise java unit-3_chapter-1-jsp
Enterprise  java unit-3_chapter-1-jspEnterprise  java unit-3_chapter-1-jsp
Enterprise java unit-3_chapter-1-jsp
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGES
 
Jsp tutorial
Jsp tutorialJsp tutorial
Jsp tutorial
 
JavaScript, often abbreviated as JS, is a programming language and core techn...
JavaScript, often abbreviated as JS, is a programming language and core techn...JavaScript, often abbreviated as JS, is a programming language and core techn...
JavaScript, often abbreviated as JS, is a programming language and core techn...
 
JSP Technology I
JSP Technology IJSP Technology I
JSP Technology I
 

Último

High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 

Último (20)

High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 

JSP overview

  • 1. Submitted By: Dipen Modi (160110107030) NarsinganiAmisha (160110107031) Vivek Nathani (160110107032) Guided By: Dr. Hetal Gaudani
  • 2.  Java Server Pages(JSP) is a technology for developing portable java web applications that runs on a java web server.  Main motivation behind developing JSP was to develop a technology so that a non-java programmer or a person with little knowledge of java could write web applications for java platform.  Initially JSP was developed to replace servlet but now common practice is to use servlet and JSP together using MVC(model-view-controller) pattern.  JSP allows developer to write html (static content),JSP action tags and java (dynamic content) code in the same page.  JSPS are compiled into java servlets by a JSP compiler, thus internally JSP page is converted into servlet, it is must to understand java servlet technology thoroughly for becoming a good JSP programmer.
  • 3.  Java Server Pages (JSP) supports dynamic content which helps developers insert java code in HTML pages by making use of special JSP tags, most of which start with <% and end with %>.  JSP enables you to separate the dynamic content of a web page from its presentation.  It caters to different types of developers:  Web designers, who are responsible for the graphical design of the page.  Java developers, who write the code to generate dynamic content.
  • 4. The JSP pages follows these phases:  Translation of JSP page  Compilation of JSP page  Class loading (class file is loaded by the class loader)  Instantiation (object of the generated servlet is created).  Initialization ( jspinit() method is invoked by the container).  Request processing ( _jspservice() method is invoked by the container).  Destroy ( jspdestroy() method is invoked by the container).
  • 5.
  • 6. 1. Translation of JSPto Servlet code  WebContainertranslates JSPcodeinto aservletsource(.java)file.  Thisisthe firststepin its tediousmultiple phaselife cycle.  Inthetranslation phase,thecontainervalidatesthe syntacticcorrectnessof theJSPpages and tagfiles.  The container interprets the standard directives and actions, and the custom actions referencing tag libraries usedin thepage. 2. Compilation ofServlet to bytecode  The JSPengine compiles the servlet into an executable class and forwards the original request to a servlet engine.  The translation of a JSPsource page into its implementation class can happen at any time between initial deployment of the JSPpage into the JSPcontainer and the receipt and processing of a client request for the targetJSPpage.
  • 7. 3. LoadingServlet class • Thejavaservlet classthat wascompiledfrom the JSPsourceisloaded into thecontainer. 4. Creatingservletinstance • In this executionphasethe container managesoneor more instances of this classin responseto requests and otherevents. 5. Initialization bycallingjspInit() method  WhenacontainerloadsaJSPit invokesthejspInit()methodbefore servicinganyrequests. If youneedto performJSP-specificinitialization,override the jspInit().  Typically, initialization is performed only once and aswith the servlet init method, you generally initialize databaseconnections,openfiles,andcreatelookuptablesinthejspInit method. public void jspInit() { //initializing the code }
  • 8. 6.RequestProcessingbycalling_jspService() method  Thisphaseof the JSPlife cyclerepresentsall interactions with requests until the JSPis destroyed.  Whenever abrowser requests aJSPandthe pagehasbeen loadedandinitialized, the JSPengine invokesthe _jspService()method in theJSP.  The_jspService()method takesanHttpServletRequest andanHttpServletResponseasits parameters . • void _jspService(HttpServletRequest request, • HttpServletResponse response) { // Service handling code... }  The_jspService()method of aJSPisinvoked onrequest basis.Thisisresponsiblefor generating the responsefor thatrequest.
  • 9. 7. DestroyingbycallingjspDestroy() method  Thedestruction phaseof the JSPlife cyclerepresentswhen aJSPisbeingremoved from usebya container.  ThejspDestroy()method isthe JSPequivalentof the destroy method forservlets.  Override jspDestroy(),whenyouneedto perform anycleanup,suchasreleasingdatabase connectionsor closingopenfiles. public void jspDestroy() { //Your cleanup code goes here. }  Whenthecallto destroymethod ismadethen,theservletisreadyfor agarbagecollection  Thisisthe endof the JSPlifecycle.
  • 10. The following steps explain how the web server creates the web page using JSP:  As with a normal page, browser sends an HTTP request to the web server.  The web server recognizes that the HTTP request is for a JSP page and forwards it to a JSP engine.This is done by using the URL or JSP page which ends with .jsp instead of .html.  The JSP engine loads the JSP page from disk and converts it into a servlet content.This conversion is very simple in which all template text is converted to println( ) statements and all JSP elements are converted to Java code that implements the corresponding dynamic behavior of the page.  The JSP engine compiles the servlet into an executable class and forwards the original request to a servlet engine.  A part of the web server called the servlet engine loads the Servlet class and executes it. During execution, the servlet produces an output in HTML format, which the servlet engine passes to the web server inside an HTTP response.  The web server forwards the HTTP response to your browser in terms of static HTML content.  Finally web browser handles the dynamically generated HTML page inside the HTTP response exactly as if it were a static page.
  • 11.  Servlets provide a way to generate dynamic documents that is both easier to write and faster to run.  provide all the powerfull features of JAVA, such as Exception handling and garbage collection.  Servlet enables easy portability across Web Servers.  Servlet can communicate with different servlet and servers.  Since all web applications are stateless protocol, servlet uses its own API to maintain session
  • 12.  Designing in servlet is difficult and slows down the application.  Writing complex business logic makes the application difficult to understand.  You need a Java Runtime Environment on the server to run servlets. CGI is a completely language independent protocol, so you can write CGIs in whatever languages you have available (including Java if you want to).
  • 13.  Allows tag based programming. So extensive java knowledge is not required.  Use nine implicit objects, which we can use directly in our JSP program  Modification done in JSP program will be recognized by underlying server automatically without reloading of web application.  Allows us to use separate presentation logic (html code) from Java code(business logic).  Increases readability of code because of tags.  Gives built-in JSP tags and also allows to develop custom JSP tags and to use third party supplied tags  Takes care of exception handling  Suitable for both java and non java programmer
  • 14.  Debugging JSP programs is still a major challenge.You have to remember that a jsp page will be first converted to a .java file and then compiled.Thus, any errors will be pointing to line numbers in the converted .java file and not the .jsp page.For example an error in the first line of .jsp page may be shown on the 20th line of the .java file.Tracing back can be somewhat tricky.  Database connectivity is not as easy as it should be. Most of the servlet engine vendors do not support connection pooling natively, as of this day. Consequently, one has to write a lot of custom code to do the job.  It is not an easy task to choose the appropriate servlet engine.  There are numerous syntax related issues with JSP programming.
  • 15. Servlet JSP Servlet is faster than jsp JSP is slower than Servlet because it first translate into java code then compile. In Servlet, if we modify the code then we need recompilation, reloading, restarting the server. It means it is time consuming process. In JSP, if we do any modifications then just we need to click on refresh button and recompilation, reloading, restart the server is not required. Servlet is a java code. JSP is tag based approach. In Servlet, there is no such method for running JavaScript at client side. In JSP, we can use the client side validations using running the JavaScript at client side. To run a Servlet you have to make an entry of Servlet mapping into the deployment descriptor file i.e. web.xml file externally. For running a JSP there is no need to make an entry of Servlet mapping into the web.xml file externally, you may or not make an entry for JSP file as welcome file list. Coding of Servlet is harden than jsp. Coding of jsp is easier than Servlet because it is tag based.
  • 16. Servlet JSP In MVC pattern, Servlet plays a controller role. In MVC pattern, JSP is used for showing output data i.e. in MVC it is a view. Servlet accept all protocol request. JSP will accept only http protocol request. In Servlet, service() method need to override. In JSP no need to override service() method. In Servlet, by default session management is not enabled we need to enable explicitly. In JSP, session management is automatically enabled. In Servlet we do not have implicit object. It means if we want to use an object then we need to get object explicitly from the servlet. In JSP, we have implicit object support. In Servlet, we need to implement business logic, presentation logic combined. In JSP, we can separate the business logic from the presentation logic by uses java Bean technology. In Servlet, all package must be imported on top of the servlet. In JSP, package imported anywhere top, middle and bottom.