SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt? (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)
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
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
 

Kürzlich hochgeladen (20)

Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).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
 

servlets and jsp