SlideShare ist ein Scribd-Unternehmen logo
1 von 24
WHAT IS JSP???
    JSP is a java based technology used to simplify the development of
dynamic web pages. JSP is used to separate dynamic content of web page
from its content with the help of HTML and JSP tags. Current version is 2.1.
WHAT THE WEB ARCHITECTURE OF JSP?
JSP MODEL I ARCHITECTURE
JSP MODEL II ARCHITECTURE
HOW MANY STAGES IN JSP LIFE CYCLE
FIVE STAGES OF JSP LIFE CYCLE

1. Page Translation stage
2. Page compilation stage
3. Loading & initialization stage
4. Request handling stage
5. Destroying stage
JSP LIFE CYCLE AS……….
WHAT ARE JSP ELEMENTS AN
THEIR TYPES????
WHAT ARE JSP ELEMENTS?????
JSP page consist of elements and templates data .These elements are described in different elements type are: -
Directives:- JSP directives provides the page resources and their properties. Some are as:-
1. Page directive :-Used to provide page specific properties
Eg:<%@page contentType=”text/html” language=”java” %>
Attributes are:-
1.   Autoflush=”true/false”
2.   Buffer=”in KB”
3.   contentType=”info”
4.   errorPage=”page url”
5.   extends=”classname”
6.   import=”package separated by comma”
7.   info=”infotext”
8.   isELIgnored=”true/false”
9.   isErrorPage=”pagenameurl”
10. isThreadSafe=”true/false”
11. language=”java”
12. pageEncoding=”ISO-8859-1”
13. session=”true/false”
WHAT ARE JSP ELEMENTS?????

2. Include Directives:-
The include directives tells the container to add the defined resource content inline to the JSP page
during the translation time .This tag used to make reusability.
Eg :-
<%@ include file=”header.html” %>

3. Taglib Directives:-
Taglib tag is used to include external tag library in your web page.


Attributes are:-
1.Uri=”url of taglibrary”
2.tagDir=”tag library directory”
3.prefix=”like object for library”
HOW MANY SCRIPTING ELEMENTS USED IN
JSP?????



•   1. <%! This is a declaration %>
•   2. <% this is a scriptlet %>
•   3. <% = this is an expression %>
NOW I AM DESCRIBING ACTION ELEMENTS IN
JSP ?????????
DESCRIBING ACTION ELEMENTS IN JSP
            ?????????


 Action elements are certain directives that are given
   to the container perform certain task during the
              execution of a JSP page.
DESCRIBING ACTION ELEMENTS IN JSP ?????????

1. <JSP:useBean>:-
The useBean tag is used to create instance for specified java bean for JSP
page.
Attributes of this tag:-
Id => what the object name you want to specifiy for this bean.
Scope => whats the scope of bean object page,request,session or
application.
Class => case sensitive name of bean class
beanName => a valid bean name no include the bean classname
type => optional attribute java class has been defined.
DESCRIBING ACTION ELEMENTS IN JSP ?????????

• 1. <JSP:getProperty> :-
• this action used to access the defines property to bean object.But it is
  important to declare bean object using useBean tag.
• Attributes are:-
• 1. name :- The name of object where to retrieve object properties.
• 2. property: - Name of property to get.
• Eg:-
• <jsp:getProperty name=”beanname”property=”propertyname”>
DESCRIBING ACTION ELEMENTS IN JSP ?????????

• 1. <JSP:getProperty> :-
this action used to access the defines property to bean object.But it
is important to declare bean object using useBean tag.
Attributes are:-
1. name :- The name of object where to retrieve object properties.
2. property: - Name of property to get.
Eg:-
<jsp:getProperty
name=”beanname”property=”propertyname”>
DESCRIBING ACTION ELEMENTS IN JSP ?????????

. <JSP:setProperty> :-
This action element is used to set the property of bean object specified by usebean tag.
Attributes are:-
1.Name :- name of bean which have to specify value
2.Property:-
name of property value to be set we can also use * to specify all the property of bean.but in this
case you have to specify the name of components as bean property.
3.Param:- The name of the request parameter whose value you want to give to a bean
property.this name basically come from web form.
4.Value:- the value to be assign to this property.
Eg:-
<jsp:setProperty name=”beanname” property=”propertyname” value=”tobeset” >
=”propertyname”>
NOW UNDERSTAND THIS USING EXAMPLE


 We are creating a login screen with java bean which
  check the username and password and return the
               result according to input
INDEX.JSP
<%--
   DOCUMENT : INDEX
   CREATED ON : APR 2, 2012, 12:23:12 PM
   AUTHOR : BARDHAN
--%>

<%@PAGE CONTENTTYPE="TEXT/HTML" PAGEENCODING="UTF-8"%>
<!DOCTYPE HTML>
<HTML>
  <HEAD>
    <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="TEXT/HTML; CHARSET=UTF-8">
    <TITLE>JSP PAGE</TITLE>
  </HEAD>
  <BODY>
    <FORM ACTION="CHECK.JSP" METHOD="POST">
      ENTER NAME <INPUT TYPE="TEXT" NAME="NAME" /><BR>
      ENTER PASSWORD <INPUT TYPE="PASSWORD" NAME="PASSWORD" />
      <BR/>
      <INPUT TYPE="SUBMIT" VALUE="LOGIN" />
      <INPUT TYPE="RESET" VALUE="RESET" />
    </FORM>
  </BODY>
</HTML>
CHECK.JSP PAGE:-
<%--
   DOCUMENT : CHECK
   CREATED ON : APR 2, 2012, 12:29:55 PM
   AUTHOR : BARDHAN
--%>

<%@PAGE CONTENTTYPE="TEXT/HTML" PAGEENCODING="UTF-8"%>
<!DOCTYPE HTML>
<HTML>
  <HEAD>
     <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="TEXT/HTML; CHARSET=UTF-8">
     <TITLE>JSP PAGE</TITLE>
  </HEAD>
  <BODY>
     <JSP:USEBEAN ID="LOGIN" CLASS="BEANS.LOGIN" SCOPE="PAGE">
        <JSP:SETPROPERTY NAME="LOGIN" PROPERTY="*" />
     </JSP:USEBEAN>
     YOUR NAME:<JSP:GETPROPERTY NAME="LOGIN" PROPERTY="NAME" />
     <BR>
     YOUR PASSWORD IS:<JSP:GETPROPERTY NAME="LOGIN" PROPERTY="PASSWORD" />
    <%BOOLEAN BA=LOGIN.GETRESULT();
    IF(BA)
             {
      RESPONSE.SENDREDIRECT("WELCOME.JSP");
    }
         ELSE{
       OUT.PRINTLN("THIS IS NOT RIGHT USERNAME OR PASSWORD");
         }

%>
  </BODY>
</HTML>
•
•   Bean.login bean:-                                 public void setName(String name) {
    /*                                                  this.name = name;
     * To change this template, choose                }
    Tools | Templates                                 public String getPassword() {
     * and open the template in the editor.             return password;
     */                                               }
    package beans;
                                                    public void setPassword(String
                                                  password) {
    /**                                               this.password = password;
     *                                              }
     * @author BARDHAN                              public boolean getResult()
                                                    {
     */
    public class login                            if(this.name.equals("sanju")&&password.eq
    {                                             uals("123"))
       private String name;                              {
                                                           result=true;
       private String password;
       private boolean result;                            }
                                                          else
                                                          {
      public String getName() {                            result=false;
        return name;                                      }
      }                                                   return result;
                                                      }
                                                  }
DESCRIBING ACTION ELEMENTS IN JSP ?????????

4. .<JSP:param>:-
This action element is used to pass the parameter to other action
elements. For example
<jsp:forward page=”hello.jsp”>
<jsp:param name=”id” value=”12” />
</jsp:forward>
DESCRIBING ACTION ELEMENTS IN JSP ?????????

•   5.<jsp:include> :-
•   This action element is used to include any jsp file in your web page.
•   <jsp:include page=”header.jsp” flush=”true|false” />
•   6.<jsp:forward> :-
•   Used to forward request control to next page .For example
•   <jsp:forward page=”next.jsp” ></jsp:forward>
•
•   7.<jsp:expression>:- work like expression script
•   8.<jsp:scriptlet> :- work like as script element
•   9.<jsp:declaration> :-work as declaration element
DESCRIBING THE JSP IMPLICIT
OBJECTS…………………….

JSP Implicit objects are described as follows
1. Application :- Used as Servlet Context object in servlets
2. Config:- Used as ServletConfig object in servlets
3. Out :- JSPWriter object to print any thing on jsp page
4. Page:- work like as Object class object
5. pageContext:- PageConext for JSP page
6. request: work like as ServletRequest object
7. response:- work like as ServletResponse Object in Servlets
8. session :- like as httpSession.

Weitere ähnliche Inhalte

Was ist angesagt?

Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
Guo Albert
 

Was ist angesagt? (20)

Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
Jsp chapter 1
Jsp chapter 1Jsp chapter 1
Jsp chapter 1
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
 
Servlets
ServletsServlets
Servlets
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
Java 8 - Features Overview
Java 8 - Features OverviewJava 8 - Features Overview
Java 8 - Features Overview
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
 
Java
JavaJava
Java
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
HTTP Request Header and HTTP Status Code
HTTP Request Header and HTTP Status CodeHTTP Request Header and HTTP Status Code
HTTP Request Header and HTTP Status Code
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
 
Node.js File system & Streams
Node.js File system & StreamsNode.js File system & Streams
Node.js File system & Streams
 
Express js
Express jsExpress js
Express js
 
REST API and CRUD
REST API and CRUDREST API and CRUD
REST API and CRUD
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
Servlets
ServletsServlets
Servlets
 
Spring boot
Spring bootSpring boot
Spring boot
 

Ă„hnlich wie Jsp presentation

13 java beans
13 java beans13 java beans
13 java beans
snopteck
 
First java-server-faces-tutorial-en
First java-server-faces-tutorial-enFirst java-server-faces-tutorial-en
First java-server-faces-tutorial-en
techbed
 
Link.javaLink.javapackage com.bookstore.domain.model;import .docx
Link.javaLink.javapackage com.bookstore.domain.model;import .docxLink.javaLink.javapackage com.bookstore.domain.model;import .docx
Link.javaLink.javapackage com.bookstore.domain.model;import .docx
SHIVA101531
 
Create an advance data type to represent web page history. Name this .pdf
Create an advance data type to represent web page history. Name this .pdfCreate an advance data type to represent web page history. Name this .pdf
Create an advance data type to represent web page history. Name this .pdf
sanuoptical
 
Ajax Tags Advanced
Ajax Tags AdvancedAjax Tags Advanced
Ajax Tags Advanced
AkramWaseem
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)
Fabien Potencier
 

Ă„hnlich wie Jsp presentation (20)

java beans
java beansjava beans
java beans
 
Struts database access
Struts database accessStruts database access
Struts database access
 
13 java beans
13 java beans13 java beans
13 java beans
 
Java beans
Java beansJava beans
Java beans
 
Using java beans(ii)
Using java beans(ii)Using java beans(ii)
Using java beans(ii)
 
Introduction to hibernate
Introduction to hibernateIntroduction to hibernate
Introduction to hibernate
 
First java-server-faces-tutorial-en
First java-server-faces-tutorial-enFirst java-server-faces-tutorial-en
First java-server-faces-tutorial-en
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ Etsy
 
Link.javaLink.javapackage com.bookstore.domain.model;import .docx
Link.javaLink.javapackage com.bookstore.domain.model;import .docxLink.javaLink.javapackage com.bookstore.domain.model;import .docx
Link.javaLink.javapackage com.bookstore.domain.model;import .docx
 
Java Script Best Practices
Java Script Best PracticesJava Script Best Practices
Java Script Best Practices
 
Maze
MazeMaze
Maze
 
Codemotion appengine
Codemotion appengineCodemotion appengine
Codemotion appengine
 
Create an advance data type to represent web page history. Name this .pdf
Create an advance data type to represent web page history. Name this .pdfCreate an advance data type to represent web page history. Name this .pdf
Create an advance data type to represent web page history. Name this .pdf
 
Zend Framework and the Doctrine2 MongoDB ODM (ZF1)
Zend Framework and the Doctrine2 MongoDB ODM (ZF1)Zend Framework and the Doctrine2 MongoDB ODM (ZF1)
Zend Framework and the Doctrine2 MongoDB ODM (ZF1)
 
JSP Part 2
JSP Part 2JSP Part 2
JSP Part 2
 
Ajax Tags Advanced
Ajax Tags AdvancedAjax Tags Advanced
Ajax Tags Advanced
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
 
KMUTNB - Internet Programming 5/7
KMUTNB - Internet Programming 5/7KMUTNB - Internet Programming 5/7
KMUTNB - Internet Programming 5/7
 

KĂĽrzlich hochgeladen

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
Christopher Logan Kennedy
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

KĂĽrzlich hochgeladen (20)

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Jsp presentation

  • 1. WHAT IS JSP??? JSP is a java based technology used to simplify the development of dynamic web pages. JSP is used to separate dynamic content of web page from its content with the help of HTML and JSP tags. Current version is 2.1.
  • 2. WHAT THE WEB ARCHITECTURE OF JSP?
  • 3. JSP MODEL I ARCHITECTURE
  • 4. JSP MODEL II ARCHITECTURE
  • 5. HOW MANY STAGES IN JSP LIFE CYCLE
  • 6. FIVE STAGES OF JSP LIFE CYCLE 1. Page Translation stage 2. Page compilation stage 3. Loading & initialization stage 4. Request handling stage 5. Destroying stage
  • 7. JSP LIFE CYCLE AS……….
  • 8. WHAT ARE JSP ELEMENTS AN THEIR TYPES????
  • 9. WHAT ARE JSP ELEMENTS????? JSP page consist of elements and templates data .These elements are described in different elements type are: - Directives:- JSP directives provides the page resources and their properties. Some are as:- 1. Page directive :-Used to provide page specific properties Eg:<%@page contentType=”text/html” language=”java” %> Attributes are:- 1. Autoflush=”true/false” 2. Buffer=”in KB” 3. contentType=”info” 4. errorPage=”page url” 5. extends=”classname” 6. import=”package separated by comma” 7. info=”infotext” 8. isELIgnored=”true/false” 9. isErrorPage=”pagenameurl” 10. isThreadSafe=”true/false” 11. language=”java” 12. pageEncoding=”ISO-8859-1” 13. session=”true/false”
  • 10. WHAT ARE JSP ELEMENTS????? 2. Include Directives:- The include directives tells the container to add the defined resource content inline to the JSP page during the translation time .This tag used to make reusability. Eg :- <%@ include file=”header.html” %> 3. Taglib Directives:- Taglib tag is used to include external tag library in your web page. Attributes are:- 1.Uri=”url of taglibrary” 2.tagDir=”tag library directory” 3.prefix=”like object for library”
  • 11. HOW MANY SCRIPTING ELEMENTS USED IN JSP????? • 1. <%! This is a declaration %> • 2. <% this is a scriptlet %> • 3. <% = this is an expression %>
  • 12. NOW I AM DESCRIBING ACTION ELEMENTS IN JSP ?????????
  • 13. DESCRIBING ACTION ELEMENTS IN JSP ????????? Action elements are certain directives that are given to the container perform certain task during the execution of a JSP page.
  • 14. DESCRIBING ACTION ELEMENTS IN JSP ????????? 1. <JSP:useBean>:- The useBean tag is used to create instance for specified java bean for JSP page. Attributes of this tag:- Id => what the object name you want to specifiy for this bean. Scope => whats the scope of bean object page,request,session or application. Class => case sensitive name of bean class beanName => a valid bean name no include the bean classname type => optional attribute java class has been defined.
  • 15. DESCRIBING ACTION ELEMENTS IN JSP ????????? • 1. <JSP:getProperty> :- • this action used to access the defines property to bean object.But it is important to declare bean object using useBean tag. • Attributes are:- • 1. name :- The name of object where to retrieve object properties. • 2. property: - Name of property to get. • Eg:- • <jsp:getProperty name=”beanname”property=”propertyname”>
  • 16. DESCRIBING ACTION ELEMENTS IN JSP ????????? • 1. <JSP:getProperty> :- this action used to access the defines property to bean object.But it is important to declare bean object using useBean tag. Attributes are:- 1. name :- The name of object where to retrieve object properties. 2. property: - Name of property to get. Eg:- <jsp:getProperty name=”beanname”property=”propertyname”>
  • 17. DESCRIBING ACTION ELEMENTS IN JSP ????????? . <JSP:setProperty> :- This action element is used to set the property of bean object specified by usebean tag. Attributes are:- 1.Name :- name of bean which have to specify value 2.Property:- name of property value to be set we can also use * to specify all the property of bean.but in this case you have to specify the name of components as bean property. 3.Param:- The name of the request parameter whose value you want to give to a bean property.this name basically come from web form. 4.Value:- the value to be assign to this property. Eg:- <jsp:setProperty name=”beanname” property=”propertyname” value=”tobeset” > =”propertyname”>
  • 18. NOW UNDERSTAND THIS USING EXAMPLE We are creating a login screen with java bean which check the username and password and return the result according to input
  • 19. INDEX.JSP <%-- DOCUMENT : INDEX CREATED ON : APR 2, 2012, 12:23:12 PM AUTHOR : BARDHAN --%> <%@PAGE CONTENTTYPE="TEXT/HTML" PAGEENCODING="UTF-8"%> <!DOCTYPE HTML> <HTML> <HEAD> <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="TEXT/HTML; CHARSET=UTF-8"> <TITLE>JSP PAGE</TITLE> </HEAD> <BODY> <FORM ACTION="CHECK.JSP" METHOD="POST"> ENTER NAME <INPUT TYPE="TEXT" NAME="NAME" /><BR> ENTER PASSWORD <INPUT TYPE="PASSWORD" NAME="PASSWORD" /> <BR/> <INPUT TYPE="SUBMIT" VALUE="LOGIN" /> <INPUT TYPE="RESET" VALUE="RESET" /> </FORM> </BODY> </HTML>
  • 20. CHECK.JSP PAGE:- <%-- DOCUMENT : CHECK CREATED ON : APR 2, 2012, 12:29:55 PM AUTHOR : BARDHAN --%> <%@PAGE CONTENTTYPE="TEXT/HTML" PAGEENCODING="UTF-8"%> <!DOCTYPE HTML> <HTML> <HEAD> <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="TEXT/HTML; CHARSET=UTF-8"> <TITLE>JSP PAGE</TITLE> </HEAD> <BODY> <JSP:USEBEAN ID="LOGIN" CLASS="BEANS.LOGIN" SCOPE="PAGE"> <JSP:SETPROPERTY NAME="LOGIN" PROPERTY="*" /> </JSP:USEBEAN> YOUR NAME:<JSP:GETPROPERTY NAME="LOGIN" PROPERTY="NAME" /> <BR> YOUR PASSWORD IS:<JSP:GETPROPERTY NAME="LOGIN" PROPERTY="PASSWORD" /> <%BOOLEAN BA=LOGIN.GETRESULT(); IF(BA) { RESPONSE.SENDREDIRECT("WELCOME.JSP"); } ELSE{ OUT.PRINTLN("THIS IS NOT RIGHT USERNAME OR PASSWORD"); } %> </BODY> </HTML>
  • 21. • • Bean.login bean:- public void setName(String name) { /* this.name = name; * To change this template, choose } Tools | Templates public String getPassword() { * and open the template in the editor. return password; */ } package beans; public void setPassword(String password) { /** this.password = password; * } * @author BARDHAN public boolean getResult() { */ public class login if(this.name.equals("sanju")&&password.eq { uals("123")) private String name; { result=true; private String password; private boolean result; } else { public String getName() { result=false; return name; } } return result; } }
  • 22. DESCRIBING ACTION ELEMENTS IN JSP ????????? 4. .<JSP:param>:- This action element is used to pass the parameter to other action elements. For example <jsp:forward page=”hello.jsp”> <jsp:param name=”id” value=”12” /> </jsp:forward>
  • 23. DESCRIBING ACTION ELEMENTS IN JSP ????????? • 5.<jsp:include> :- • This action element is used to include any jsp file in your web page. • <jsp:include page=”header.jsp” flush=”true|false” /> • 6.<jsp:forward> :- • Used to forward request control to next page .For example • <jsp:forward page=”next.jsp” ></jsp:forward> • • 7.<jsp:expression>:- work like expression script • 8.<jsp:scriptlet> :- work like as script element • 9.<jsp:declaration> :-work as declaration element
  • 24. DESCRIBING THE JSP IMPLICIT OBJECTS……………………. JSP Implicit objects are described as follows 1. Application :- Used as Servlet Context object in servlets 2. Config:- Used as ServletConfig object in servlets 3. Out :- JSPWriter object to print any thing on jsp page 4. Page:- work like as Object class object 5. pageContext:- PageConext for JSP page 6. request: work like as ServletRequest object 7. response:- work like as ServletResponse Object in Servlets 8. session :- like as httpSession.