Q: What is JSP?
A: JavaServer Pages (JSP) is a
technology for developing web pages that support dynamic content which helps
developers insert java code in HTML pages by making use of special JSP tags,
most of which start with <% and end with %>.
Q: What are
advantages of using JSP?
A: JSP offer several
advantages as listed below:
Performance is significantly
better because JSP allows embedding Dynamic Elements in HTML Pages itself.
JSP are always compiled before
it's processed by the server unlike CGI/Perl which requires the server to load
an interpreter and the target script each time the page is requested.
JavaServer Pages are built on
top of the Java Servlets API, so like Servlets, JSP also has access to all the
powerful Enterprise Java APIs, including JDBC, JNDI, EJB, JAXP etc.
JSP pages can be used in
combination with servlets that handle the business logic, the model supported
by Java servlet template engines.
Q:What are the
advantages of jsp over servlet?
A: The advantage of JSP is that they are document-centric. Servlets, on the other hand, look and act like programs. A Java Server Page can contain Java program fragments that instantiate and execute Java classes, but these occur inside an HTML template file and are primarily used to generate dynamic content.
A: The advantage of JSP is that they are document-centric. Servlets, on the other hand, look and act like programs. A Java Server Page can contain Java program fragments that instantiate and execute Java classes, but these occur inside an HTML template file and are primarily used to generate dynamic content.
Some of the JSP functionality
can be achieved on the client, using JavaScript. The power of JSP is that it is
server-based and provides a framework for Web application development.
What are the
different types of JSP tags?
The different
types of JSP tags are as follows:
Q: What is the life
cycle of jsp?
A: Life cyle of jsp:
Translation
Compilation
Loading the class
Instantiating the class
jspInit()
_jspService()
jspDestroy()
Q:What jsp life
cycle method can I override?
A: You cannot override the
_jspService() method within a JSP page. You can however, override the jspInit()
and jspDestroy() methods within a JSP page. JspInit() can be useful for allocating
resources like database connections, network connections, and so forth for the
JSP page. It is good programming practice to free any allocated resources
within jspDestroy().
Q: What are
implicit objects in jsp?
A: Implicit objects in JSP are
the Java objects that the JSP Container makes available to developers in each
page. These objects need not be declared or instantiated by the JSP author.
They are automatically instantiated by the container and are accessed using
standard variables; hence, they are called implicit objects.
Q:
Difference Between include Directive
and include Action of JSP
This JSP interview
question is a continuation of earlier question I just made it a
separate one to write answer in clear tabular format.
Include Directive
|
Include Action
|
include directive
is processed at the translation time
|
Include action
is processed at the run time.
|
include directive
can use relative or absolute path
|
Include action
always use relative path
|
Include directive
can only include contents of resource it will not process the
dynamic resource
|
Include action
process the dynamic resource and result will be added to calling JSP
|
We can not pass
any other parameter
|
Here we can pass
other parameter also using JSP:param
|
We cannot
pass any request or response object to calling jsp to included file or JSP or
vice versa
|
In this case
it’s possible.
|
Q: What are the JSP implicit objects ?
JSP provides 9 implicit
objects bydefault.They are as follows:
|
Object
|
Type
|
1) out
|
JspWriter
|
2) request
|
HttpServletRequest
|
3) response
|
HttpServletResponse
|
4) config
|
ServletConfig
|
5) session
|
HttpSession
|
6) application
|
ServletContext
|
7) pageContext
|
PageContext
|
8) page
|
Object
|
9) exception
|
Throwable
|
Q:
|
|||||
A:
|
A declaration declares one
or more variables or methods for use later in the JSP source file.A
declaration must contain at least one complete declarative statement. You can
declare any number of variables or methods within one declaration tag, as
long as they are separated by semicolons. The declaration must be valid in
the scripting language used in the JSP file.
<%! somedeclarations %> <%! int i = 0; %> <%! int a, b, c; %>
|
||||
Q:
|
|
A:
|
1.
A scriptlet can contain any number of
language statements, variable or method declarations, or expressions that are
valid in the page scripting language.Within scriptlet tags, you can1.Declare
variables or methods to use later in the file (see also Declaration).
2.
Write expressions valid in the page scripting
language (see also Expression).
3.
Use any of the JSP implicit objects or any
object declared with a <jsp:useBean> tag.
You must write plain text, HTML-encoded text, or other JSP tags outside the scriptlet.
Scriptlets are executed at
request time, when the JSP engine processes the client request. If the
scriptlet produces output, the output is stored in the out object, from which
you can display it.
|
Q:
|
|
A:
|
When you invoke a forward
request, the request is sent to another resource on the server, without the
client being informed that a different resource is going to process the
request. This process occurs completly with in the web container. When a
sendRedirtect method is invoked, it causes the web container to return to the
browser indicating that a new URL should be requested. Because the browser
issues a completly new request any object that are stored as request
attributes before the redirect occurs will be lost. This extra round trip a
redirect is slower than forward.
|
The main motive of the Big data service providers is to spread the knowledge so that they can give more big data engineers to the world.
ReplyDelete