SlideShare une entreprise Scribd logo
1  sur  36
JAVA SERVER PAGES
by Tanmoy Barman
cont:-
barmantanmoy.47@gmail.com
DISCUSSIONS
 Introduction
 JSP vs. ASP
 JSP life cycles
 JSP errors
 JSP comments
 JSP elements; Directives, Scripting, Actions
 JSP implicit objects
 Example of writing JSP
 Java Bean
INTRODUCTION
 JSP is a technology based in java which produces dynamic web
pages.
 JSP is a server side scripting language technology created by
sun micro systems.
 JSP files are html files which contains special tags where java
code is embedded into it.
 JSP have .jsp extension.
JSP VS. ASP
 JSP is technology introduced by Sun micro systems where as
ASP is a technology introduced y Microsoft.
 JSP is abbreviation of JAVA SERVER PAGES and ASP is
abbreviation of ACTIVE SERVER PAGES
 ASP pages can connect to my sql & ms Access databases and
also can connect to other database with the help of ADO
whereas JSP can connect to any database loading the
appropriate driver when needed.
JSP VS. ASP
 ASP runs on Microsoft IIS server which run on Microsoft
operating system where as JSP can run on any Linux based
server, IBM JBOSS as well as in Microsoft platform.
 ASP is an interpreted language, JSP can interpreted as well as
compiled.
 JSP is free of cost including JSP server where as ASP is free
but running ASP on Microsoft IIS server cost money.
JSP LIFE CYCLES
 JSP are deployed in the web server as servlet.
 The JSP page is compiled to servlet by JSP engine, eliminating
the html tags and putting them inside out.println() statements
and removing the jsp tags.
 Once it is translated into servlet then the servlet, then it
follows the servlet lifecycles.
JSP LIFE CYCLES
JSP ERRORS
 Three types of error can be evolved in JSP:-
 Jsp error; which occurs when jsp is translated to servlet.
 Java code error; occurs when the servlet is complied to java class.
 HTML error; occurs during the presentation of html pages in the
browser.
JSP ERRORS
 The first two errors (jsp error and java code error) is detected
by the application server.
 The HTML error is detected by the web browser.
JSP COMMENTS
 Comments can be include in the jsp page, follows:-
 <%-- --%>
 </* */>
 <!-- --!>
JSP ELEMENTS
 The elements in jsp contains the tags, each having special
meanings, containing java codes which tells the jsp engine
what/how dynamic output has to processed.
 There are three types of elements:-
 Directives
 Scripting
 Action
DIRECTIVES
 Directives:- This tag is used to convey special information
about the page to the jsp engine.
 Syntax:-
 <%@ %>
 Three kinds of Directives are available:-
 page
 include
 tag library
DIRECTIVES
 page directive ; this directive informs the jsp engine about the
headers and facilities that the page should get from the
environment.
 There can be any number of page directives in a jsp page.
 Declared usually at the top.
 Syntax:-
 <%@page attribute= %>
 Attributes can be; include, import, session, etc.
 Example; <%@page import=“package_name”%>
DIRECTIVES
 Include directive ; this is used to statically include one or
more resources to the jsp page.
 This allows the jsp developer to reuse the code.
 Syntax:-
 <%@include page=“”%>
 There is only on attribute named „page‟ in include directive.
SCRIPTING ELEMENTS
 Scripting Elements; contains embedded java code.
 There are three types:-
 Declarations
 Expression
 Scriplets
SCRIPTING ELEMENTS
 Declarations; this tag allows the developer to declare one or
multiple variable and methods.
 They do not produce any output.
 Syntax:-
 <%! %>
 Example:- <%! public String name;
public int age;
public void setDetail(name,age); %>
SCRIPTING ELEMENTS
 Expression; this tag allows the developer to embed single java
expression which is not terminated by a semi colon.
 Syntax:-
 <%= %>
 Example:- <%= new java.util.Date() %>
SCRIPTING ELEMENTS
 Scriplets; this tag allows the developer to embedded java code
inside it that can use the variable declared earlier.
 Syntax:-
 <% %>
 Example:- <% int sum=a+b;
system.out.println(sum);
%>
ACTION ELEMENT
 Functions provided like:-
 Use of java bean technology in jsp page.
 Browser independent support for applet.
 Transfers control among pages.
 Syntax:-
 <jsp: />
ACTION ELEMENT
 Standard action tag are:-
 useBean
 setProperty
 getProperty
 param
 include
 forward
 plugin
JSP IMPLICIT OBJECTS
 There are certain objects in jsp that can be used in jsp page without being
declared these are Implicit objects. There are nine implicit object in JSP:-
 application
 page
 pageContext
 config
 session
 exception
 request
 response
 out
EXAMPLE OF JSP
 A simple jsp program to show date using scriplets;” teddyTest.jsp”
<html>
<head>
</head>
<body>
<h1>JSP Page to show today Date </h1>
<% out.println(new java.util.Date()); %>
</body>
</html>
EXAMPLE OF JSP
 Now we will use the implicit object to get values from a html page.
 This is a html page to take user inputs “Impli.html”
<html>
<body>
<form ACTION=“ImpliShow.jsp”>
Name=<input type=“text” name=“nm”>
<input type=“submit”>
</form>
</body>
</html>
EXAMPLE OF JSP
 ImpliShow.jsp
<html>
<body>
<%
String nm=request.getParameter("usr");
String ag=request.getParameter("age");
out.println (“name:”+nm+””+age:”+ag);
%>
</body>
</html>
JAVA BEAN
 Java bean is a self contained class file in java which typically
contains;
 No argument constructor.
 Is seriliziable.
 Have getter and setter methods to get and set values of the
properties.
 According to java white papers java beans are reusable
component in java, and they combine various objects into a
single one which can be accessed by multiple user.
JAVA BEAN
 Jsp use three action tag for use of java bean technology:-
 useBean=used to locate or instantiate a bean class.
 setProperty=set the property value or values of a bean class.
 getProperty=get the property values of a bean class, first the
property values are converted into string and then added to the
request stream.
JAVA BEAN
 <jsp:useBean id= "instanceName" scope= "page | request |
session | application"
class= "packageName.className"
type= "packageName.className“
beanName=“ packgeName.className | <%= expression >" >
</jsp:useBean>
JAVA BEAN
 Example of useBean action tag in jsp:-
 Class student{
private String name;
Private int age;
public void setName(string n){
name=n;}
publci void setAge(int a){
age=n;}
}
JAVA BEAN
 A html page named bean.html
<html>
<body>
<form ACTION=“teddyBean.jsp”>
Name=<input type=“text” name=“nm”>
<input type=“submit”>
</form>
</body>
</html>
JAVA BEAN
 A jsp page named teddyBean.jsp
<html>
<body>
<jsp:useBean id=“obj” class=“student”>
<%
Sting n=request.getParameter(“name”);
obj.setName(n);
system.out.println(obj.getName());
%>
</body>
</html>
JAVA BEAN
 <jsp:setProperty name="instanceOfBean" property= "*" |
property="propertyName" param="parameterName" |
property="propertyName" value="{ string | <%= expression
%>}" />
 <jsp:getProperty name="instanceOfBean"
property="propertyName" />
JAVA BEAN
 <jsp:setProperty name=“obj" property="name" value="*" />
 To set all the values of the property.
 <jsp:setProperty name=“obj” property=“_property”
value=“_value” />
 To set a particular property with a value.
JAVA BEAN
 Example of setProperty and getProperty action tag:-
Package teddyPack
public class jB {
private String name;
private int age;
public void setAge(int age){this.age=age;}
public void setName(String name){this.name=name;}
public String getName(){return name;}
public int getAge(){ return age;}
}
JAVA BEAN
 A html page named “setGET.html”
<html>
<body>
<form ACTION=“setGet.jsp”>
Name:<input type=“text” name=“name”>
Age:<input type=“text” name=“age”>
<input type=“submit”>
</form>
</body></html>
JAVA BEAN
 A jsp page named “setGet.jsp”
<html>
<body>
<jsp:useBean id="ted" class="teddyPack.jB" />
<% String n=request.getParameter("name");%>
<jsp:setProperty name="ted" property="name" value="*" />
<b>HELLO</b><jsp:getProperty name="ted" property="name"/>; aged
<jsp:getProperty name=“ted” property=“age”/>
</body>
</html>
THANK YOU

Contenu connexe

Tendances

JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)Talha Ocakçı
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)Manisha Keim
 
1 java servlets and jsp
1   java servlets and jsp1   java servlets and jsp
1 java servlets and jspAnkit Minocha
 
Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course JavaEE Trainers
 
Java Servlets
Java ServletsJava Servlets
Java ServletsNitin Pai
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technologyTanmoy Barman
 
Jsp elements
Jsp elementsJsp elements
Jsp elementsNuha Noor
 
Javax.servlet,http packages
Javax.servlet,http packagesJavax.servlet,http packages
Javax.servlet,http packagesvamsi krishna
 
Servlet/JSP course chapter 1: Introduction to servlets
Servlet/JSP course chapter 1: Introduction to servletsServlet/JSP course chapter 1: Introduction to servlets
Servlet/JSP course chapter 1: Introduction to servletsJavaEE Trainers
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsKaml Sah
 
Java Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsJava Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsBG Java EE Course
 
Servlet and jsp interview questions
Servlet and jsp interview questionsServlet and jsp interview questions
Servlet and jsp interview questionsSujata Regoti
 

Tendances (20)

Jsp sasidhar
Jsp sasidharJsp sasidhar
Jsp sasidhar
 
Jsp chapter 1
Jsp chapter 1Jsp chapter 1
Jsp chapter 1
 
JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)
 
Jsp Introduction Tutorial
Jsp Introduction TutorialJsp Introduction Tutorial
Jsp Introduction Tutorial
 
Jsp element
Jsp elementJsp element
Jsp element
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
 
1 java servlets and jsp
1   java servlets and jsp1   java servlets and jsp
1 java servlets and jsp
 
Jsp servlets
Jsp servletsJsp servlets
Jsp servlets
 
Java Servlets & JSP
Java Servlets & JSPJava Servlets & JSP
Java Servlets & JSP
 
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 Servlets
Java ServletsJava Servlets
Java Servlets
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technology
 
Jsp elements
Jsp elementsJsp elements
Jsp elements
 
Java servlets
Java servletsJava servlets
Java servlets
 
Javax.servlet,http packages
Javax.servlet,http packagesJavax.servlet,http packages
Javax.servlet,http packages
 
Servlet/JSP course chapter 1: Introduction to servlets
Servlet/JSP course chapter 1: Introduction to servletsServlet/JSP course chapter 1: Introduction to servlets
Servlet/JSP course chapter 1: Introduction to servlets
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - Components
 
Java Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsJava Server Faces (JSF) - Basics
Java Server Faces (JSF) - Basics
 
JDBC in Servlets
JDBC in ServletsJDBC in Servlets
JDBC in Servlets
 
Servlet and jsp interview questions
Servlet and jsp interview questionsServlet and jsp interview questions
Servlet and jsp interview questions
 

Similaire à Java server pages (20)

Jsp in Servlet by Rj
Jsp in Servlet by RjJsp in Servlet by Rj
Jsp in Servlet by Rj
 
JSP.pptx
JSP.pptxJSP.pptx
JSP.pptx
 
WEB TECHNOLOGIES JSP
WEB TECHNOLOGIES  JSPWEB TECHNOLOGIES  JSP
WEB TECHNOLOGIES JSP
 
Jsp and jstl
Jsp and jstlJsp and jstl
Jsp and jstl
 
Jsp tutorial
Jsp tutorialJsp tutorial
Jsp tutorial
 
Introduction to JSP.pptx
Introduction to JSP.pptxIntroduction to JSP.pptx
Introduction to JSP.pptx
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGES
 
anatomy of a jsp page & jsp syntax.pptx
anatomy of a jsp page & jsp syntax.pptxanatomy of a jsp page & jsp syntax.pptx
anatomy of a jsp page & jsp syntax.pptx
 
Jsp
JspJsp
Jsp
 
Jsp
JspJsp
Jsp
 
Java server pages
Java server pagesJava server pages
Java server pages
 
J2EE jsp_01
J2EE jsp_01J2EE jsp_01
J2EE jsp_01
 
Java Web Programming [4/9] : JSP Basic
Java Web Programming [4/9] : JSP BasicJava Web Programming [4/9] : JSP Basic
Java Web Programming [4/9] : JSP Basic
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 7 ...
 
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
 
SCWCD : Java server pages CHAP : 9
SCWCD : Java server pages  CHAP : 9SCWCD : Java server pages  CHAP : 9
SCWCD : Java server pages CHAP : 9
 
Spatial approximate string search Doc
Spatial approximate string search DocSpatial approximate string search Doc
Spatial approximate string search Doc
 
JAVA SERVER PAGES
JAVA SERVER PAGESJAVA SERVER PAGES
JAVA SERVER PAGES
 

Plus de Tanmoy Barman

JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivityTanmoy Barman
 
Web apps architecture
Web apps architectureWeb apps architecture
Web apps architectureTanmoy Barman
 
introduction to channel borrowing scheme in cellular networks
introduction to channel borrowing scheme in cellular networksintroduction to channel borrowing scheme in cellular networks
introduction to channel borrowing scheme in cellular networksTanmoy Barman
 
INTRODUCTION TO CLOUD COMPUTING
INTRODUCTION TO CLOUD COMPUTINGINTRODUCTION TO CLOUD COMPUTING
INTRODUCTION TO CLOUD COMPUTINGTanmoy Barman
 

Plus de Tanmoy Barman (6)

Java rmi
Java rmiJava rmi
Java rmi
 
Jini
JiniJini
Jini
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
Web apps architecture
Web apps architectureWeb apps architecture
Web apps architecture
 
introduction to channel borrowing scheme in cellular networks
introduction to channel borrowing scheme in cellular networksintroduction to channel borrowing scheme in cellular networks
introduction to channel borrowing scheme in cellular networks
 
INTRODUCTION TO CLOUD COMPUTING
INTRODUCTION TO CLOUD COMPUTINGINTRODUCTION TO CLOUD COMPUTING
INTRODUCTION TO CLOUD COMPUTING
 

Dernier

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 

Dernier (20)

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 

Java server pages

  • 1. JAVA SERVER PAGES by Tanmoy Barman cont:- barmantanmoy.47@gmail.com
  • 2. DISCUSSIONS  Introduction  JSP vs. ASP  JSP life cycles  JSP errors  JSP comments  JSP elements; Directives, Scripting, Actions  JSP implicit objects  Example of writing JSP  Java Bean
  • 3. INTRODUCTION  JSP is a technology based in java which produces dynamic web pages.  JSP is a server side scripting language technology created by sun micro systems.  JSP files are html files which contains special tags where java code is embedded into it.  JSP have .jsp extension.
  • 4. JSP VS. ASP  JSP is technology introduced by Sun micro systems where as ASP is a technology introduced y Microsoft.  JSP is abbreviation of JAVA SERVER PAGES and ASP is abbreviation of ACTIVE SERVER PAGES  ASP pages can connect to my sql & ms Access databases and also can connect to other database with the help of ADO whereas JSP can connect to any database loading the appropriate driver when needed.
  • 5. JSP VS. ASP  ASP runs on Microsoft IIS server which run on Microsoft operating system where as JSP can run on any Linux based server, IBM JBOSS as well as in Microsoft platform.  ASP is an interpreted language, JSP can interpreted as well as compiled.  JSP is free of cost including JSP server where as ASP is free but running ASP on Microsoft IIS server cost money.
  • 6. JSP LIFE CYCLES  JSP are deployed in the web server as servlet.  The JSP page is compiled to servlet by JSP engine, eliminating the html tags and putting them inside out.println() statements and removing the jsp tags.  Once it is translated into servlet then the servlet, then it follows the servlet lifecycles.
  • 8. JSP ERRORS  Three types of error can be evolved in JSP:-  Jsp error; which occurs when jsp is translated to servlet.  Java code error; occurs when the servlet is complied to java class.  HTML error; occurs during the presentation of html pages in the browser.
  • 9. JSP ERRORS  The first two errors (jsp error and java code error) is detected by the application server.  The HTML error is detected by the web browser.
  • 10. JSP COMMENTS  Comments can be include in the jsp page, follows:-  <%-- --%>  </* */>  <!-- --!>
  • 11. JSP ELEMENTS  The elements in jsp contains the tags, each having special meanings, containing java codes which tells the jsp engine what/how dynamic output has to processed.  There are three types of elements:-  Directives  Scripting  Action
  • 12. DIRECTIVES  Directives:- This tag is used to convey special information about the page to the jsp engine.  Syntax:-  <%@ %>  Three kinds of Directives are available:-  page  include  tag library
  • 13. DIRECTIVES  page directive ; this directive informs the jsp engine about the headers and facilities that the page should get from the environment.  There can be any number of page directives in a jsp page.  Declared usually at the top.  Syntax:-  <%@page attribute= %>  Attributes can be; include, import, session, etc.  Example; <%@page import=“package_name”%>
  • 14. DIRECTIVES  Include directive ; this is used to statically include one or more resources to the jsp page.  This allows the jsp developer to reuse the code.  Syntax:-  <%@include page=“”%>  There is only on attribute named „page‟ in include directive.
  • 15. SCRIPTING ELEMENTS  Scripting Elements; contains embedded java code.  There are three types:-  Declarations  Expression  Scriplets
  • 16. SCRIPTING ELEMENTS  Declarations; this tag allows the developer to declare one or multiple variable and methods.  They do not produce any output.  Syntax:-  <%! %>  Example:- <%! public String name; public int age; public void setDetail(name,age); %>
  • 17. SCRIPTING ELEMENTS  Expression; this tag allows the developer to embed single java expression which is not terminated by a semi colon.  Syntax:-  <%= %>  Example:- <%= new java.util.Date() %>
  • 18. SCRIPTING ELEMENTS  Scriplets; this tag allows the developer to embedded java code inside it that can use the variable declared earlier.  Syntax:-  <% %>  Example:- <% int sum=a+b; system.out.println(sum); %>
  • 19. ACTION ELEMENT  Functions provided like:-  Use of java bean technology in jsp page.  Browser independent support for applet.  Transfers control among pages.  Syntax:-  <jsp: />
  • 20. ACTION ELEMENT  Standard action tag are:-  useBean  setProperty  getProperty  param  include  forward  plugin
  • 21. JSP IMPLICIT OBJECTS  There are certain objects in jsp that can be used in jsp page without being declared these are Implicit objects. There are nine implicit object in JSP:-  application  page  pageContext  config  session  exception  request  response  out
  • 22. EXAMPLE OF JSP  A simple jsp program to show date using scriplets;” teddyTest.jsp” <html> <head> </head> <body> <h1>JSP Page to show today Date </h1> <% out.println(new java.util.Date()); %> </body> </html>
  • 23. EXAMPLE OF JSP  Now we will use the implicit object to get values from a html page.  This is a html page to take user inputs “Impli.html” <html> <body> <form ACTION=“ImpliShow.jsp”> Name=<input type=“text” name=“nm”> <input type=“submit”> </form> </body> </html>
  • 24. EXAMPLE OF JSP  ImpliShow.jsp <html> <body> <% String nm=request.getParameter("usr"); String ag=request.getParameter("age"); out.println (“name:”+nm+””+age:”+ag); %> </body> </html>
  • 25. JAVA BEAN  Java bean is a self contained class file in java which typically contains;  No argument constructor.  Is seriliziable.  Have getter and setter methods to get and set values of the properties.  According to java white papers java beans are reusable component in java, and they combine various objects into a single one which can be accessed by multiple user.
  • 26. JAVA BEAN  Jsp use three action tag for use of java bean technology:-  useBean=used to locate or instantiate a bean class.  setProperty=set the property value or values of a bean class.  getProperty=get the property values of a bean class, first the property values are converted into string and then added to the request stream.
  • 27. JAVA BEAN  <jsp:useBean id= "instanceName" scope= "page | request | session | application" class= "packageName.className" type= "packageName.className“ beanName=“ packgeName.className | <%= expression >" > </jsp:useBean>
  • 28. JAVA BEAN  Example of useBean action tag in jsp:-  Class student{ private String name; Private int age; public void setName(string n){ name=n;} publci void setAge(int a){ age=n;} }
  • 29. JAVA BEAN  A html page named bean.html <html> <body> <form ACTION=“teddyBean.jsp”> Name=<input type=“text” name=“nm”> <input type=“submit”> </form> </body> </html>
  • 30. JAVA BEAN  A jsp page named teddyBean.jsp <html> <body> <jsp:useBean id=“obj” class=“student”> <% Sting n=request.getParameter(“name”); obj.setName(n); system.out.println(obj.getName()); %> </body> </html>
  • 31. JAVA BEAN  <jsp:setProperty name="instanceOfBean" property= "*" | property="propertyName" param="parameterName" | property="propertyName" value="{ string | <%= expression %>}" />  <jsp:getProperty name="instanceOfBean" property="propertyName" />
  • 32. JAVA BEAN  <jsp:setProperty name=“obj" property="name" value="*" />  To set all the values of the property.  <jsp:setProperty name=“obj” property=“_property” value=“_value” />  To set a particular property with a value.
  • 33. JAVA BEAN  Example of setProperty and getProperty action tag:- Package teddyPack public class jB { private String name; private int age; public void setAge(int age){this.age=age;} public void setName(String name){this.name=name;} public String getName(){return name;} public int getAge(){ return age;} }
  • 34. JAVA BEAN  A html page named “setGET.html” <html> <body> <form ACTION=“setGet.jsp”> Name:<input type=“text” name=“name”> Age:<input type=“text” name=“age”> <input type=“submit”> </form> </body></html>
  • 35. JAVA BEAN  A jsp page named “setGet.jsp” <html> <body> <jsp:useBean id="ted" class="teddyPack.jB" /> <% String n=request.getParameter("name");%> <jsp:setProperty name="ted" property="name" value="*" /> <b>HELLO</b><jsp:getProperty name="ted" property="name"/>; aged <jsp:getProperty name=“ted” property=“age”/> </body> </html>