0% found this document useful (0 votes)
9 views4 pages

advanceJavaQuestions Part3

Advance Java Interview Questions

Uploaded by

Dos_Santos
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)
9 views4 pages

advanceJavaQuestions Part3

Advance Java Interview Questions

Uploaded by

Dos_Santos
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

Question:7 What you can stop the browser to cash your page?

Answer:7 Instead of deleting a cache, you can force the browser not to
catch the page.
<%
[Link]("pragma","no-cache");//HTTP 1.1
[Link]("Cache-Control","no-cache");
[Link]("Cache-Control","no-store");
[Link]("Expires", -1);
[Link]("max-age", 0);
//[Link] ("Expires", -1); //prevents caching at the proxy
server
[Link]("cache-Control", "private");

%>
put the above code in your page.
Question8: What you will handle the runtime exception in your jsp
page?
Answer:8 The errorPage attribute of the page directive can be used to
catch run-time exceptions automatically and then forwarded to an error
processing page.
For example:
<%@ page errorPage="[Link]" %>
above code forwards the request to "[Link]" page if an uncaught
exception is encountered during request processing. Within
"[Link]", you must indicate that it is an error-processing page,
via the directive: <%@ page isErrorPage="true" %>.

Question9:Diffrence between forward and sendredirect?

Answer:9 1)The <jsp:forward> element forwards the request object


containing the client request information from one JSP file to another
file. The target file can be an HTML file, another JSP file, or a servlet, as
long as it is in the same application context as the forwarding JSP file.
sendRedirect sends HTTP temporary redirect response to the browser,
and browser creates a new request to go the redirected page. The
[Link] kills the session variables.
Question 10:Define and explain in short jsp implicit objects?
Answer:10)Implicit objects are the objects available to the JSP page.
These objects are created by Web container and contain information
related to a particular request, page, or application. The JSP implicit
objects are:

Variable Class Description


The context for the JSP page's
applicati [Link]
servlet and any Web components
on ontext
contained in the same application.
[Link] Initialization information for the
config
onfig JSP page's servlet.
exceptio Accessible only from an error
[Link]
n page.
[Link]
out The output stream.
iter
The instance of the JSP page's
servlet processing the current
page [Link]
request. Not typically used by JSP
page authors.
The context for the JSP page.
pageCon [Link]
Provides a single API to manage
text Context
the various scoped attributes.
Subtype of
The request triggering the
request [Link]
execution of the JSP page.
quest
Subtype of The response to be returned to the
response [Link] client. Not typically used by JSP
sponse page authors.
[Link]
session The session object for the client.
Session

Question 11) What is the difference between <jsp:include page = ... >
and <%@ include file = ... >?
Answer:11) Both the tag includes the information from one page in
another. The differences are as follows:
<jsp:include page = ... >: This is like a function call from one jsp to
another jsp. It is executed (the included page is executed and the
generated html content is included in the content of calling jsp) each time
the client page is accessed by the client. This approach is useful to for
modularizing the web application. If the included file changed then the
new content will be included in the output.

<%@ include file = ... >: In this case the content of the included file is
textually embedded in the page that have <%@ include file="..">
directive. In this case in the included file changes, the changed content
will not included in the output. This approach is used when the code from
one jsp file required to include in multiple jsp files.

Question 12)What types of comments are available in the JSP?


Answer:12) There are two types of comments are allowed in the JSP.
These are hidden and output comments. A hidden comments does not
appear in the generated output in the html, while output comments
appear in the generated output.
Example of hidden comment:
<%-- This is hidden comment --%> also called as jsp comment
Example of output comment:
<!-- This is output comment --> also called as html comment

Question 13) What do you understand by JSP Actions?


Answer:13 JSP actions are XML tags that direct the server to use existing
components or control the behavior of the JSP engine. JSP Actions
consist of a typical (XML-based) prefix of "jsp" followed by a colon,
followed by the action name followed by one or more attribute
parameters.

There are six JSP Actions:


<jsp:include/>
<jsp:forward/>
<jsp:plugin/>
<jsp:usebean/>
<jsp:setProperty/>
<jsp:getProperty/>

You might also like