Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
37 views
5 pages
CHP 12 Ej
Java
Uploaded by
Arati Behera
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save chp 12 ej For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
37 views
5 pages
CHP 12 Ej
Java
Uploaded by
Arati Behera
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save chp 12 ej For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save chp 12 ej For Later
You are on page 1
/ 5
Search
Fullscreen
Jnvaserver Pages ree 85 CHAPTER OMEMOMSMOMOMOMoHEHCID UNIT - Il t | JAVASERVER i : PAGES | ; omomromcencennenenceaceate [12.1 Introduction to Javaserver Pages | JavaServer Pages (JSP) is a technology used to develop interactive Web pages. JSP was developed by Sun Microsystems and is an improved version of Java servlets. JSP may be developed in a simplified manner and has a wide range of applications. As with most server-based technologies, JSP separates business logic from the presentation layer. JSPs are normal HTML. pages with embedded Java code. To process a JSP file, developers need a JSP engine, which is connected to a Web server. The JSP page is then compiled into a servlet, which is handled by the servlet engine. This phase is known as translation. The servlet engine then loads the servlet class and executes it to create dynamic HTML, which is then sent to the browser. When the next page is requested, the JSP page is precompiled into the servlet and executed, unless the JSP page is changed. When used with Java DataBase Connectivity (DBC), JSP provides a dynamic way to create database-driven websites. [12.2 Why Use Javaserver Pages? 12.2.1 Advantages of JSP over servlet © Extension to Servlet : JSP technology is the extension to servlet technology, We can Use all the features of servlet in JSP. In addition to, we can use implicit objec Predefined tags, expression language and Custom tags in JSP that makes JSP development easy. ® Easy to maintain : JSP can be easily managed because we can easily separate our business logic with presentation logic. In servlet technology, we mix our business logic with the presentation logic. © Fast Development : No need to recompile and redeploy, If JSP page is modified, we don't need to recompile and redeploy the project. The servlet code needs to be updated and recompiled if we have to change the look and feel of the application, © Less code than Servlet : In JSP, we can use a lot of tags such as action tags, JSTL, custom tags etc. that reduces the code, Also, we can use EL, implicit objects ete, © The JSP serves all facilities of Java i.e. write once run anywhere, ° Th implified scripting lang, sed syntax for e1 ; 1s ee JSP uses simplified scripting language based syntax for embedding HTML intoKe q 2 = Enterprise aoa (T-Y.B S617) (Sem. p © JSP containers provide easy coding for accessing standard objects and actions, © The JSP use HTTP as default request /response communication model. 12.1.2 Advantages of JSP over Other Technologies than Servlets © Versus active server pages (ASP) : ASP is given by Microsoft. It is also a tag-baseg programming language. ASP cocle is not portable. However, JSP code is portable because itis written in Java which is portable language. We can use Java for JSP, we need not stick with a particular server product or IIS. © Versus PHP : It is an HTML embedded scripting language and it is also open source software like Java. It is similar to JSP and ASP. It is not suitable for large scal application and banking applications where money transaction occurs because of security reasons. For PHP we have to learn one new language. © Versus JavaScript : JavaScript is in no way related with Java programming, Iti normally used to generate HTML dynamically on the client machine. JavaScript isnot Suitable for network programming and to access server-side resources, Java is more powerful, flexible, reliable and portable than PHP. © Versus HTML : Regular HTML, that is dynamic information. So it does not react to user server side resources. JSP contains both static an contains HTML, [12.2 DISADVANTAGES OF JSP © Output is HTML which is not rich in features, © Difficult to debug/trace errors since compiled. static HTML, does not contain input and is also not fit for accessing id non-static content. As static part, it JSP pages are translated into servlets and © JSP pages require more time when accessed compiled on the server. © Database connectivity is not as easy as it should be. Most of the servlet engine vendors do not support connection pooling natively © Numerous syntax related issues with JSP programming © _ JSP pages require about double the disk [12.3 JSP ws. Servlets © Servlet is faster than JSP, While JSP is slower java code then compile. © In Servlet, if we modify reloading, restarting the server> It means it is time consuming process, While In JSP, if we do a*Y modifications then just we need to clic and. recompilatio” reloading, and restart the server is not required, Servlet isa pure java code. While JSP is tag based approach, : : | © In Servlet, there is no such method for runnin, JavaScript at client si ile In JSP we can use the client side validations using re aes ae | © To run a Servlet you have to make an entry of Servlet me into'the mest descriptor file i.e. web xml file externally, While For running a S30) thaws ePeeed make an entry of Servlet mapping into the webseet i for the first time as they are to be space to hold the page than servlet. than Servlet because it first translate int? fi nd make an entry for JSP file as welcome file ist ile externally, you may oF © Coding of Servlet is harden than JSP. While Codi ea - because it is tag based. odling of JSP is easier than SeF MVC pattern, Servlet plays a controller role, Whit fot ic Mowing cule data ie.in MVC itis view, ® MVC pattern, JSP is usedfae 87 sere ges wet Servlet accept all protocol request. While JSP will accept only hitp protocol request. ° In Servlet, Service( ) method need to override. Whi © gervice( ) method. In JSP no need to override In Servlet, by default session management is not enabled we need to enable explicitly. © While In JSP, session management is automatically enabled InServiet we do not have implicit object. I means if we want to use an object then we # eed to get object explicitly form the servlet, While In JSP, we have implicit object support. ; ; : : In Servlet, we need to implement business logic, presentation logic combined, While * in JSP, we can separate the business logic from the presentation logic by uses JavaBean technology. @ InServlet, all package must be imported on top of the servlet. While In JSP, package imported anywhere top, middle and bottom. 124 Life Cycle of AJSP Page ] The page cant outputs the content directly to the browser it relies on early server side processing process which translates JSP page into the JSP Page class. The page class then will handle all the requests made of JSP. [sSP page (isp) ISP Translation Servlet (java) HTTP Servlet loaded JSP Compilation Response Servlet (class) WEB CONTAINER JSPs life cycle can be grouped into following phases 1. JSP Page Translation : A java Servlet file is generated from the JSP source file, This is the first step in its dull multiple phase life cycle. In the translation phase, the container validates the syntax of the JSP page and tag files for correctness. The container interprets the standard directives and actions, and the custom actions referencing tag libraries used in the page. JSP Page Compilation : After the page translation the generated java Servlet file is compiled into a java Servlet class. The translation of implementation class can happen at any time between ini JSP page into the JSP container and the for the target JSP page. Class Loading : The java Servlet class that was compiled from the JSP source is loaded into the container, a JSP page into its ial deployment of the receipt and processing of a client request Execution phase : In this phase the container adlust one or more inst Glass in response to requests and other events, Interface [spPage cannot 7 and « s. Interface JspPage contains jsptnit and ispDeiroy }pethod. The JSP specification has provided a sper interac lspPage for JSP pages serving HTTP sts interfac Ptblepbage for ISP ag 8 equests and this interface containe 5. Initialization : jspinit() method is i : called ins ei Miseed ony eect) method is al instantly after the instance was created, ‘ances of this tp.Enterprise Java (T.Y.B.Sc.-I.T.) (Sem.-V) 1 68 ror ution : This method is called for every request of this JSP Breet gee ‘This is where it serves the purpose of creation. It has to pas through all the above steps to reach this phase. It passes the request and the response objects. jepService( ) method cannot be overridden. 7, jspDestroy( ) execution : This method is called when this JSP page is destroyed, With this call the Servlet serves its purpose and submits itself to garbage collection. This is the end of JSP life cycle. 12.5 HOW DOES A JSP FUNCTION? ] The web server needs a JSP engine, i.e, a container to process JSP pages. The JSP container is responsible for intercepting, requests for JSP pages. A JSP container works with the Web server to provide the runtime environment and other services a JSP needs. It knows how to understand the special elements that are part of JSPs. Following diagram shows the position of JSP container and JSP files in a Web application | HTML Handler handler forced on to HTML files, Process Java ISPTags || Compiter Runtime 12.6 How Does JSP Execute? The following steps explain how the web server creates the W © Aswith a normal page, your browser sends an HTTP req ° The = server recognizes that the HTTP request is for a 10 a JSP engine. This is d i to 2 JSP engine lone by using the URL or JSP p; @ The JSP engine loads the JSP is iti Lied tbarialerpadis 3s Page from disk and converts it into a servlet content are con} the corresponding dynamic behaviour eee od © The JSP engine compiles the servi original request to a serviet engine. © A part of the web server called the serviet i a ents Daring exccton the eves prdiy on Serle lass id ebpage using JSP ; uest to the web server. JSP page and forwards it age which ends with jsP et into an executable class and forwards thenee ree 89 ‘The output is furthur passed on to the web server by the servlet engine inside an HTTP response. @ The web server forwards the HTTP response to ‘your browser in terms of static HTML content. © Finally, the web browser handles the dynamically-generated HTML page inside the HTTP response exactly as if it were a static page. ‘Typically, the JSP engine checks to see whether a servlet for a JSP file already exists and whether the modification date on the JSP is older than the servlet. If the JSP is older than its generated servlet, the JSP container assumes that the JSP hasn't changed and that the generated servlet still matches the JSP's contents. This makes the process more efficient than with the other scripting languages (such as PHP) and therefore faster. So in a way, a JSP page is really just another way to write a servlet without having to be a Java programming wiz. Except for the translation phase, a JSP page is handled exactly like a regular servlet. 12.7 About Javaserver Pages 2.3 The JavaServer Pages (SP) 23 feature provides full support for the JSP 23 specification. Descriptions of the new JSP 2.3 functions are provided in the JSP 2.3 specification and are not described here. However, the new specification additions are minor, as compared to the JSP 2.2 feature : © Support for Expression Language (EL) 3.0 @ Availability of Servlet 3.1 APIs toa JSP. © There are no known behavior differences between JSP 2.2 and JSP 2.3 that directly prevent a JSP that runs with JSP 2.2 from successfully running with JSP 23. However, if a JSP uses Expression Language (EL) or Servlet API functions, you must consider the changes between Servlet 3.1 and Servlet 3.0, and between EL 3.0 and EL 2.2. QUESTIONS What is JSP? Explain its advantages and disadvantages. What are the advantages of JSP over technologies other than Servlet? Differentiate between Servlet and JSP. Explain the phases of JSP life cycle. Explain JSP functionality and execution. serene wae
You might also like
Java - Lecture 6 - Java Server Pages
PDF
No ratings yet
Java - Lecture 6 - Java Server Pages
405 pages
JavaServerPages Material
PDF
No ratings yet
JavaServerPages Material
67 pages
Unit 3 JSP
PDF
No ratings yet
Unit 3 JSP
61 pages
Chapter 7 JSP
PDF
No ratings yet
Chapter 7 JSP
62 pages
CH 3
PDF
No ratings yet
CH 3
36 pages
Lesson 4 - Java JSP
PDF
No ratings yet
Lesson 4 - Java JSP
62 pages
Java Server Pages 416
PDF
No ratings yet
Java Server Pages 416
46 pages
2.java Server Pages
PDF
No ratings yet
2.java Server Pages
34 pages
Unit 5 - JSP
PDF
No ratings yet
Unit 5 - JSP
93 pages
Intro JSPTechnology
PDF
No ratings yet
Intro JSPTechnology
22 pages
@ Java JSP
PDF
No ratings yet
@ Java JSP
47 pages
JSP Basics
PDF
No ratings yet
JSP Basics
129 pages
Web Technologies
PDF
No ratings yet
Web Technologies
14 pages
Unit IV - JSP, Web Services, Sturts - PPTX 1
PDF
No ratings yet
Unit IV - JSP, Web Services, Sturts - PPTX 1
132 pages
JSP 1
PDF
No ratings yet
JSP 1
15 pages
U-4 JSP
PDF
No ratings yet
U-4 JSP
98 pages
Lecture 43
PDF
No ratings yet
Lecture 43
15 pages
BCA AWT Unit 5
PDF
No ratings yet
BCA AWT Unit 5
56 pages
Unit 3 Chapter 1
PDF
No ratings yet
Unit 3 Chapter 1
12 pages
Unit 3 Je
PDF
No ratings yet
Unit 3 Je
24 pages
JSP (Java Server Pages)
PDF
No ratings yet
JSP (Java Server Pages)
81 pages
Unit Iv
PDF
No ratings yet
Unit Iv
60 pages
Introduction To JSP
PDF
No ratings yet
Introduction To JSP
23 pages
Server Side Scripting With JSP
PDF
No ratings yet
Server Side Scripting With JSP
70 pages
Ajp CHP 6
PDF
No ratings yet
Ajp CHP 6
8 pages
JSP in Java II Unit
PDF
No ratings yet
JSP in Java II Unit
14 pages
5 Introduction To JSP
PDF
No ratings yet
5 Introduction To JSP
37 pages
Java Server Pages Notess
PDF
No ratings yet
Java Server Pages Notess
26 pages
Programming
PDF
100% (1)
Programming
203 pages
AJP U3 Notes
PDF
No ratings yet
AJP U3 Notes
52 pages
JSP Notes
PDF
No ratings yet
JSP Notes
10 pages
Chapter 5hjhhfguihfyutufyytufuyuyyifytug
PDF
No ratings yet
Chapter 5hjhhfguihfyutufyytufuyuyyifytug
28 pages
EJ Unit 3
PDF
No ratings yet
EJ Unit 3
24 pages
6 English
PDF
No ratings yet
6 English
3 pages
JSP Introduction
PDF
No ratings yet
JSP Introduction
4 pages
15advanced JAVA For Beginners JSP, JSTL, JSON and SERVLET TUTORIALS... Etc (Learn With Examples)
PDF
No ratings yet
15advanced JAVA For Beginners JSP, JSTL, JSON and SERVLET TUTORIALS... Etc (Learn With Examples)
303 pages
Web Technology Practical No. 6
PDF
No ratings yet
Web Technology Practical No. 6
13 pages
U 5 JSP
PDF
No ratings yet
U 5 JSP
68 pages
Unit 3 - Chp2
PDF
No ratings yet
Unit 3 - Chp2
11 pages
AssignmentFile 571 07122023140329
PDF
No ratings yet
AssignmentFile 571 07122023140329
12 pages
1 - WT - JSP Main
PDF
No ratings yet
1 - WT - JSP Main
52 pages
JSP Consolidated
PDF
No ratings yet
JSP Consolidated
12 pages
U4.1 JSP SERV
PDF
No ratings yet
U4.1 JSP SERV
7 pages
8 Java Module7 JSP
PDF
No ratings yet
8 Java Module7 JSP
21 pages
JSPBOOK
PDF
No ratings yet
JSPBOOK
13 pages
JSP Presentation
PDF
100% (5)
JSP Presentation
18 pages
Enterprise Java Unit 3
PDF
No ratings yet
Enterprise Java Unit 3
35 pages
JSP - PPTX ROOPAM
PDF
No ratings yet
JSP - PPTX ROOPAM
33 pages
WE Unit-4 JSP
PDF
No ratings yet
WE Unit-4 JSP
24 pages
Experiment No. 2: To Create A JSP Web Page
PDF
No ratings yet
Experiment No. 2: To Create A JSP Web Page
7 pages
JSP (Java Server Pages)
PDF
No ratings yet
JSP (Java Server Pages)
8 pages
VI SEM BCA Advanced Java - UNIT 4 - JSP-P1 MATERIAL
PDF
No ratings yet
VI SEM BCA Advanced Java - UNIT 4 - JSP-P1 MATERIAL
29 pages
JSP Notes
PDF
71% (14)
JSP Notes
35 pages
09 JSP Intro
PDF
No ratings yet
09 JSP Intro
32 pages
Advantages of JSP
PDF
No ratings yet
Advantages of JSP
10 pages
Advantages of JSP Over Servlet: Unit - 6
PDF
No ratings yet
Advantages of JSP Over Servlet: Unit - 6
6 pages
JSP What Is Javaserver Pages?: Cgi Means "Common Gateway Interface"
PDF
No ratings yet
JSP What Is Javaserver Pages?: Cgi Means "Common Gateway Interface"
9 pages
Natraj JSP
PDF
100% (1)
Natraj JSP
87 pages
JSP and Servlets in Java: Abstract
PDF
No ratings yet
JSP and Servlets in Java: Abstract
5 pages
IOT CHP 1
PDF
No ratings yet
IOT CHP 1
9 pages
DS Practical
PDF
No ratings yet
DS Practical
32 pages
Chapter 3 Ej
PDF
No ratings yet
Chapter 3 Ej
9 pages
Chapter 4 Ej
PDF
No ratings yet
Chapter 4 Ej
6 pages
CHP 10 Ej
PDF
No ratings yet
CHP 10 Ej
3 pages