JSP Interview Questions
JSP Interview Questions
© Copyright by Interviewbit
Contents
Conclusion
28. Conclusion
Java Server Pages (JSP) enables the creation of dynamic and a platform-independent
way for building web-based applications. It is a server-side programming technology.
JSP is a technology that is an integral part of Java EE, a complete platform for
enterprise-class applications. This means that JSP can be used from the simplest
applications to the most complex and demanding ones.
JavaServer Pages (JSP) o en serve the same purpose as programs implemented
using the Common Gateway Interface (CGI). However, in addition, JSP offers several
advantages as compared to CGI.
Element Description
<%@
include Includes a file during the translation phase.
... %>
<%@
Declares a tag library, containing custom actions,
taglib ...
used on the page.
%>
Element Description
Element Description
<% ...
Scriptlet used to embed scripting code.
%>
+ Addition
* Multiplication
/ or div Division
% or
Modulo (remainder)
mod
&& or
Test for logical AND
and
for(inti=0;i<n;i++)
{
//block of statements
}
While(i<n)
{
//Block of statements
}
The reque
object is u
to request
informati
like a
request javax.servlet.http.HttpServletRequest
paramete
header
informati
server nam
etc.
The respo
is an insta
of a class t
response javax.servlet.http.HttpServletResponse represent
response
can be giv
to the clie
This is use
get, set, a
remove th
pageContext javax.servlet.jsp.PageContext attributes
from a
particular
scope.
This is use
get, set, a
remove
attributes
session javax.servlet.http.HttpSession
session sc
and also u
to get sess
i f ti
Page 13 © Copyright by Interviewbit
JSP Interview Questions
17. What is J2EE?
J2EE is basically a compilation of different Java APIs that have previously been
offered as separate packages. J2EE Blueprints describe how they can all be
combined. J2EE vendors can use a test suite to test their products for compatibility.
J2EE comprises the following enterprise-specific APIs:
JavaServer Pages ( JSP)
Java Servlets
Enterprise JavaBeans (EJB)
Java Database Connection ( JDBC)
Java Transaction API ( JTA) and Java Transaction Service ( JTS)
Java Naming and Directory Interface ( JNDI)
Java Message Service ( JMS)
Java IDL and Remote Method Invocation (RMI)
Java XML
18. What is JSTL?
JSTL stands for Java server pages standard tag library. It is a collection of custom JSP
tag libraries that provide common functionality for web development.
Following are some of the properties of JSTL:
Code is Neat and Clean.
Being a Standard Tag, it provides a rich layer of the portable functionality of JSP
pages.
It has Automatic Javabeans Introspection Support. The JSTL Expression
language handles JavaBean code very easily. We don't need to downcast the
objects, which have been retrieved as scoped attributes.
Easier for humans to read and easier for computers to understand.
Iteration
Conditional logic
Catch exception
URL forward
Redirect, etc.
Following is the syntax to include a tag library:
20. Which methods are used for reading form data using JSP?
JSP is used to handle the form data parsing automatically. It dies so by using the
following methods depending on the situation:
getParameter() − To get the value of a form parameter, call the
request.getParameter() method.
getParameterValues() − If a parameter appears more than once and it returns
multiple values, call this method.
getParameterNames() − This method is used if, in the current request, you want
a complete list of all parameters.
getInputStream() − This method is used for reading binary data streams from
the client.
The JSP page is turned into a servlet for all the JSP elements to be processed by the
server. Then the servlet is executed. The servlet container and the JSP container—are
o en combined into one package under the name “web container”.
In the translation phase, the JSP container is responsible for converting the JSP page
into a servlet and compiling the servlet. This is used to automatically initiate the
translation phase for a page when the first request for the page is received.
In the “request processing” phase, the JSP container is also responsible for invoking
the JSP page implementation class to process each request and generate the
response.
When a page request of JSP is processed, the template text and the dynamic content
generated by the JSP elements are merged, and the result is sent as the response to
the browser.
jsp:forward: This action tag forwards the request and response to another
resource.
jsp:include: This action tag is used to include another resource.
jsp:useBean: This action tag is used to create and locates bean objects.
jsp:setProperty: This action tag is used to set the value of the property of the
bean.
jsp:getProperty: This action tag is used to print the value of the property of the
bean.
jsp:plugin: This action tag is used to embed another component such as the
applet.
jsp:param: This action tag is used to set the parameter value. It is used in
forward and includes mostly.
jsp:fallback: This action tag can be used to print the message if the plugin is
working.
Here <%%> tags are scriptlet tags and within it, we can place the java code.
It is an architecture that separates business logic, presentation, and data. In this, the
flow starts from the view layer, where the request is raised and processed in the
controller layer. This is then sent to the model layer to insert data and get back the
success or failure message.
Conclusion
28. Conclusion
The Java 2 Enterprise Edition (J2EE) takes the task of building an Internet presence
and transforms it to the point where developers can use Java to efficiently create
multi-tier, server-side applications. In late 1999, Sun Microsystems added a new
element to the collection of Enterprise Java tools, called the JavaServer Pages (JSP).
The JSP, built on top of Java servlets, is designed to increase the efficiency in which
programmers, and even nonprogrammers, can create web content.
JavaServer Pages helps in developing web pages that include dynamic content. A JSP
page can change its content based on any number of variable items. A JSP page not
only contains standard markup language elements like a regular web page but also
contains special JSP elements that allow the server to insert dynamic content in the
page. This combination of standard elements and custom elements allows for the
creation of powerful web apps.
References:
JavaServer Pages, 3rd Edition, O'Reilly.
Web Development with JavaServer Pages, by Duane and Mark.
Css Interview Questions Laravel Interview Questions Asp Net Interview Questions