SlideShare uma empresa Scribd logo
1 de 28
J2EE
Introduction
●

Q. What is J2EE ?
Java platform to developing enterprise web
application
Basic Architecture
Description
●

J2EE architecture : 3 tier
–

Client Tier ( Web tier)
●

–

Business Tier
●

–

The Presentation layer on the client side includes j2ee
componenets such as jsp,jsf etc
Components containing business logic of the
application such as Enterprise Beans.

Database Tier
●

This tier contains the persistence API of the application
so as to talk to database
Java Web Components
●

Servlet

●

Jsp ( Java Server Pages )

●

Jstl (Jsp Standard Tag Library)

●

Jsf ( Java Server Faces )
Servlet
●

Extends web server's functionality

●

Respond to Request from client

●

Used to generate dynamic response

●

Usually responses in HTML or Xml format

●

Most often used with HTTP protocol
Functioning of Servlet
●

●

●

Process or Store data that was submitted by
HTML forms
Provide dynamic content such as the result of
a database query
Manage State information
(in case of stateless HTTP protocol)
Packages (imports) for Servlet
●

java.io.*;
–

●

javax.servlet
–

●

Input and Output package (eg. Out.println)
Contains interaction logic between web container
and servlet

javax.servlet.http
–

Contains Http specific logic
●

javax.servlet.http.HttpServletRequest;

●

javax.servlet.http.HttpServletRespons
Servlet Skeleton
●

Imports

●

Public classname extends HttpServlet
–

Public void init()
●

–

Public void Service()
●

–

{ /* Initialization goes here */ }
{/* Business logic goes here */ }

Public void destroy()
●

{/* Free resources here */}
Lifecycle
●

Loaded and Instantiated

●

Initialization

●

Servicing the request

●

Destroying the request
●

Loaded and instantiated
–

●

Container loads servlet during startup or when the
request is made. After loading the servlet , the
container creates the instance of the servlet when
the first request come for service ,

Initialization
–

After creating the instance the container calls init()
method. The init method is called only once in
servlets lifetime. Initialization logic goes here
●

Servicing the request
–

After successful initialization , servlet will be
available to serve the request. Servlet creates
separate thread for each request

–

Service() method is called to serve the request
in short service method contains the business
logic
●

Destroying the servlet
–

If the servlet is no longer needed , the servlet
container calls the destroy() method.

–

Like the init() method destroy() method also get
called only once in servlet's lifetime

–

Destroy() method releases all the resources which
were acquired previously
JSP (Java Server Pages)
●

Jsp is a component which generates dynamic
contents

●

Jsp is a server-side technology

●

Extension : .jsp

●

Jsp usually consist of two components
–

Static Data
●

–

Can be expressed in any text based format such as
HTML

JSP elements
●

Jsp tags , which can generates dynamic contents
JSP Components
●

Declaration tag

●

Scriptlet tag

●

Expression tag

●

Directive tag

●

Action tag
●

Declaration tag:
–

Declaration is used to declare and define java
variables and methods inside your jsp

–

They are initialized when the jsp page is initialized

–

The scope of the declared variables or methods is
within the jsp page

–

Syntax : <%! int a = 10; %>
Declaration Example :
<html>
<body>
<%! int value = 10; %>
Hello World!<%= value %>
</body>
</html>
●

Scriptlet tag:
–

Scriptlets are block of java code

–

You can write any number of java code inside your
jsp using scriptlet

–

Syntax : <% ( Java Code ) %>
Scriptlet Example :
<html>
<body>
Hello World!
<%
out.println("Helloworld");
%>
</body>
</html>
●

Expression tag:
–

The code placed inside expression tag is printed
(output) , so there is no need to write out.println()

–

Mainly used to print values of variables and
methods

–

Syntax : <%= (variable or method) %>
Expression Example :
<html>
<body>
<%! int value = 10; %>
Hello World! <%= value %>
</body>
</html>
●

Directive tag:
–

Jsp directive provide directions and instructions to
the container , how to handle certain jsp
processing

–

There are 3 types of directives
●
●
●

Page directive
Include directive
Taglib directive
–

Page directive
●

●
●

Page directive is used to provide information about the
page
Example : <%@page language="java" %>
Here language is an attribute of the page directive
–

Include directive
●
●
●

Include is used to include a jsp file in the jsp page
Example : <%@ include file="/header.jsp" %>
File is an attribute which specifies which file need to
include
–

Taglib directive
●

●
●

Taglib directive is used to use the custom tags in the
jsp page ( custom tags allow us to define our own tags )
Example :
<%@ taglib uri="tlds/taglib.tld" prefix="mytag" %>
●

Action tag:
–

The action tag basically are used to control the
flow between pages and to use Java Beans
–

Some of the action tags are
●
●
●
●
●
●
●
●

Jsp:forward
Jsp:include
Jsp:useBean
Jsp:setProperty
Jsp:getPropery
Jsp:plugin
Jsp:param
Jsp:fallback

Mais conteúdo relacionado

Mais procurados (20)

Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
 
Jsp
JspJsp
Jsp
 
PL/pgSQL - An Introduction on Using Imperative Programming in PostgreSQL
PL/pgSQL - An Introduction on Using Imperative Programming in PostgreSQLPL/pgSQL - An Introduction on Using Imperative Programming in PostgreSQL
PL/pgSQL - An Introduction on Using Imperative Programming in PostgreSQL
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Jsp
JspJsp
Jsp
 
XML parsing using jaxb
XML parsing using jaxbXML parsing using jaxb
XML parsing using jaxb
 
Jsp(java server pages)
Jsp(java server pages)Jsp(java server pages)
Jsp(java server pages)
 
Jsp (java server page)
Jsp (java server page)Jsp (java server page)
Jsp (java server page)
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Jsp tutorial (1)
Jsp tutorial (1)Jsp tutorial (1)
Jsp tutorial (1)
 
Jsp sasidhar
Jsp sasidharJsp sasidhar
Jsp sasidhar
 
JSP Scope variable And Data Sharing
JSP Scope variable And Data SharingJSP Scope variable And Data Sharing
JSP Scope variable And Data Sharing
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Struts2
Struts2Struts2
Struts2
 
Laravel Level 1 (The Basic)
Laravel Level 1 (The Basic)Laravel Level 1 (The Basic)
Laravel Level 1 (The Basic)
 
Laravel level 0 (introduction)
Laravel level 0 (introduction)Laravel level 0 (introduction)
Laravel level 0 (introduction)
 
Jsp elements
Jsp elementsJsp elements
Jsp elements
 
Java server pages
Java server pagesJava server pages
Java server pages
 
Jsp
JspJsp
Jsp
 
Laravel level 2 (Let's Practical)
Laravel level 2 (Let's Practical)Laravel level 2 (Let's Practical)
Laravel level 2 (Let's Practical)
 

Destaque

Advance java natraj - satya
Advance java natraj -  satyaAdvance java natraj -  satya
Advance java natraj - satyaSatya Johnny
 
Java Abs Online Handwritten Script Recognition
Java Abs   Online Handwritten Script RecognitionJava Abs   Online Handwritten Script Recognition
Java Abs Online Handwritten Script Recognitionncct
 

Destaque (7)

Advance java natraj - satya
Advance java natraj -  satyaAdvance java natraj -  satya
Advance java natraj - satya
 
Php peers
Php peersPhp peers
Php peers
 
Java Abs Online Handwritten Script Recognition
Java Abs   Online Handwritten Script RecognitionJava Abs   Online Handwritten Script Recognition
Java Abs Online Handwritten Script Recognition
 
Xml naresh tech
Xml naresh techXml naresh tech
Xml naresh tech
 
Struts santhosh
Struts santhoshStruts santhosh
Struts santhosh
 
Java servlet
Java servletJava servlet
Java servlet
 
Java notes
Java notesJava notes
Java notes
 

Semelhante a servlets and jsp

Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2divzi1913
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2Long Nguyen
 
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology Ayes Chinmay
 
BITM3730Week12.pptx
BITM3730Week12.pptxBITM3730Week12.pptx
BITM3730Week12.pptxMattMarino13
 
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
 
Servlet., tomcat server, implicit jsp object
Servlet., tomcat server, implicit jsp objectServlet., tomcat server, implicit jsp object
Servlet., tomcat server, implicit jsp objectADITYADIXIT974283
 
JSP - Java Server Page
JSP - Java Server PageJSP - Java Server Page
JSP - Java Server PageVipin Yadav
 
Core web application development
Core web application developmentCore web application development
Core web application developmentBahaa Farouk
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsKaml Sah
 
Struts 2 Overview
Struts 2 OverviewStruts 2 Overview
Struts 2 Overviewskill-guru
 
presentation on online movie ticket booking
presentation on online movie ticket bookingpresentation on online movie ticket booking
presentation on online movie ticket bookingdharmawath
 

Semelhante a servlets and jsp (20)

Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2
 
20jsp
20jsp20jsp
20jsp
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2
 
JSP Part 1
JSP Part 1JSP Part 1
JSP Part 1
 
JSP Directives
JSP DirectivesJSP Directives
JSP Directives
 
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
 
Jsp in Servlet by Rj
Jsp in Servlet by RjJsp in Servlet by Rj
Jsp in Servlet by Rj
 
BITM3730Week12.pptx
BITM3730Week12.pptxBITM3730Week12.pptx
BITM3730Week12.pptx
 
Jsp
JspJsp
Jsp
 
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...
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Servlet., tomcat server, implicit jsp object
Servlet., tomcat server, implicit jsp objectServlet., tomcat server, implicit jsp object
Servlet., tomcat server, implicit jsp object
 
JSP - Java Server Page
JSP - Java Server PageJSP - Java Server Page
JSP - Java Server Page
 
JSP.pptx
JSP.pptxJSP.pptx
JSP.pptx
 
Core web application development
Core web application developmentCore web application development
Core web application development
 
Jsp basic
Jsp basicJsp basic
Jsp basic
 
Wt unit 4
Wt unit 4Wt unit 4
Wt unit 4
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - Components
 
Struts 2 Overview
Struts 2 OverviewStruts 2 Overview
Struts 2 Overview
 
presentation on online movie ticket booking
presentation on online movie ticket bookingpresentation on online movie ticket booking
presentation on online movie ticket booking
 

Último

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 

Último (20)

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 

servlets and jsp