We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 3
Java Interview Questions 28/30
Chapter 12
JSP
12.1 What is a JSP Page ?
‘A Java Server Page (ISP) is a text document that contains two types of text: static data and JSP elements. Static data can be
expressed in any text-based format, such as HTML or XML. JSP is a technology that mixes static content with dynamically-
generated content, See ISP example here,
12.2 How are the JSP requests handled ?
On the arrival of a JSP request, the browser first requests @ page with a sp extension. Then, the Web server reads the request and
using the JSP compiler, the Web server converts the ISP page into a servlet class. Notice that the JSP file is compiled only on
the first request of the page, or if the ISP file has changed. The generated servlet class is invoked, in order to handle the browser's
request. Once the execution of the request is over, the servlet sends a response back to the client, See how to get Request
parameters ina JSP.
12.3. What are the advantages of JSP ?
‘The advantages of using the JSP technology are shown below:
+ ISP pages are dynamically compiled into servlets and thus, the developers can easily make updates to presentation code,
+ ISP pages can be pre-compiled,
+ JSP pages can be easily combined to static templates, including HTML or XML fragments, with code that generates dynamic
content.
+ Developers can offer customized JSP tag libraries that page authors access using an XML-like syntax.
+ Developers can make logic changes at the component level, without editing the individual pages that use the application's logic.
12.4 What are Directives ? What are the different types of Directives available in
JSP?
Directives are instructions that are processed by the JSP engine, when the page is compiled to a servlet. Directives are used to
set page-level instructions, insert data from external files, and specify custom tag libraties. Directives are defined between < +@
= >, The different types of directives are shown belowJava Interview Questions 29/30
+ Include dir
ive: itis used to include a file and merges the content ofthe file with the current page.
+ Page
‘ect ive: itis used ( define specific attributes in the JSP page, like error page and buffer,
+ TagLLb: itis used to declare a custom tag library which is used in the page.
12.5 What are JSP actions ?
ISP actions use constructs in XML syntax to control the behavior of the servlet engine. JSP actions are executed when a JSP
page is requested, They can be dynamically inserted into a file, re-use JavaBeans components, forward the user to another page,
or generate HTML for the Java plugin Some of the available actions are listed below:
+ JepsincLude - includes file, when the ISP page is requested,
+ jep:useBean- finds or instantiates a JavaBean
jsp:setProperty - sets the property of a JavaBean.
+ JepigetProperty - gets the property of a JavaBean,
+ jap:for
xdl- forwards the requester to a new page.
gin - generates browser-specific code
12.6 What are Scriptlets ?
In Java Server Pages (ISP) technology, a scriptlet is a piece of Java-code embedded in a JSP page. The scriptlet is everything
inside the tags. Between these tags, a user can add any valid scriplet.
12.7. What are Decalarations ?
Declarations are similar to variable declarations in Java, Declarations are used to declare variables for subsequent use in expres-
sions or scriptlets, To add a declaration, you must use the sequences to enclose your declarations.
12.8 What are Expressions ?
A ISP expression is used to insert the value of a scripting language expression, converted into a string, into the data stream
retumed to the client, by the web server. Expressions are defined between <3 =and > tags.
12.9 What is meant by implicit objects and what are they ?
SSP implicit objects are thse Java objects thatthe JSP Container makes available to developers in each page. A developer can
call them directly, without being explicitly declared. ISP Implicit Objects are also called pre-defined variables The following
objects are considered implicit in a JSP page:
+ appli
+ page
+ requestJava Interview Questions 30/30
+ exception