0% found this document useful (0 votes)
5 views5 pages

JSP-Java Server Page

The document explains the differences between Servlets and JSP, stating that Servlets are used when there is more Java code, while JSP is preferred for dynamic web pages with more HTML. It details JSP's lifecycle, scripting elements, implicit objects, directives, and action elements, highlighting its functionality and advantages over Servlets. Additionally, it introduces Java Beans as classes with private properties and methods for managing those properties.

Uploaded by

Pranjal Nale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

JSP-Java Server Page

The document explains the differences between Servlets and JSP, stating that Servlets are used when there is more Java code, while JSP is preferred for dynamic web pages with more HTML. It details JSP's lifecycle, scripting elements, implicit objects, directives, and action elements, highlighting its functionality and advantages over Servlets. Additionally, it introduces Java Beans as classes with private properties and methods for managing those properties.

Uploaded by

Pranjal Nale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

"When we have 80% of java code & 20% of HTML code then we will use

Servlet."

"When we have 20% of java code & 80% of HTML code then we will use JSP."

JSP- Java Server Page


“JSP is use to design and run dynamic web pages on server. JSP contains
everything in foam of html but if we want to write java code inside a JSP page
we will write that code within JSP page . JSP lifecycle contain only 1 state
corresponding to service method. when we have to change in servlet, we have
to run file and run project but in JSP we can changes with the help of refresh a
page only.”

JSP

Servlet

JSP Loader
Compiler

Servlet
.class

JVM/Server

“JSP is tag support language like HTML but nested tagging of JSP tags not allow
in JSP.”

“it is more powerful then servlet and it contains more functionality in compare
to servlet.”

“We can’t use JSP tags or HTML Tags inside JSP tag. If we want use html tag,
we have separate JSP tag.”
JSP scripting element and JSP scripting tag.
there are 3 JSP scripting element and scripting tags which is use to perform
some special operation with in a JSP page .

1.Scriptlet tag- “if we want to write java code inside a JSP page we will write
that code inside scriptlet tag. and this code will put by JSP loader inside service
method of servlet.”

<% java code %> - syntax.

2.Declaration tag-“ if we want to declare a global variable or a method with


in a JSP page we will use declaration tag. if we write any code inside
declaration tag it will automatically transfer in the class of servlet by JSP
loader.“

<%! java code %>- syntax.

3.Expression tag- “if we want to print something within JSP page we will use
expression tag. it is substitution of out.println in JSP .“

<%= java code %>- syntax.

JSP implicit objects


“there are some pre-define object or classes and implementation classes of
interfaces provided by JSP which used to perform some special operation on
JSP.”
There is some implicit object :-

HttpServletRequest Request

Response

HTTP Session Session

PrintWriter out

Exception exception

JSP directives
“There are 3 JSP directive which is use to perform important operation with in a
JSP page.”

1. page directive – “if we want to import a package with in JSP page we will
use page directive it is also use to transfer error and exception from 1 JSP page
to another JSP page .”

<%@page %> syntax.

2. include directive – “ it is mainly use to include content of another JSP


page with in a JSP page.”

<%@include %> syntax.

3.taglib direct - “it is mainly used in custom tags to use or import .tld file.”

<%@taglib %> syntax.


.tld(tag library descriptor)
JSP action elements
“ there are five JSP elements which is use to perform some special operation.”

1. JSP forward – “this action element uses to transfer request and


response from 1 JSP page to another JSP , servlet and html page . it is the
substitution of out.println in JSP.”

<jsp:forword> </jsp:forword> syntax.

2. JSP include – “JSP include action element is mainly use include content
of another JSP or html page with in a JSP page .it is mainly use for single
page application .”

<jsp:include> </jsp:include> syntax.

3. JSP usebean – “JSP usebean action element is mainly use to create an


object of bean class and with the help of this object we can call the setter
and getter method of bean class.”

<jsp:usebean> </jsp:usebean> syntax.

4. JSP setproperty – “JSP setproperty action element is mainly use to set


all the properties of bean class with the help of bean object.”

<jsp:getproperty> </jsp:getproperty> syntax.

5. JSP getproperty – “JSP getproperty action element is use to fetch or


call all the getter methods with the help of bean object.”

<jsp:getproperty> </jsp:getproperty> syntax.


Java Beans
“ java beans are class that contains private properties and setter and getter
methods to set and get values of properties is called java beans.”

You might also like