Professional Documents
Culture Documents
Choice 1
JSP pages can write a Binary Stream using its implicit out stream.
Choice 2
Choice 3
JSP pages must flush their buffers before changing the stream type;
Servlets do not have this limitation.
JSP pages have more security settings than Servlets.
Choice 4
Submit
Example
Syntax
<calculate>9+10*4/2+1</calculate>
Given the above example syntax, which class is EXTENDED to implement
a custom tag that parses an expression in its body, calculates, and then
displays the result of that expression?
javax.servlet.jsp.tagext.BodyTag
Choice 1
javax.servlet.jsp.tagext.TagData
Choice 2
javax.servlet.jsp.tagext.Tag
Choice 3
javax.servlet.jsp.tagext.TagBody
Choice 4
javax.servlet.jsp.tagext.BodyTagSupport
Choice 5
Submit
Sample
Code
<html>
<body>
<jsp:include file="sidemenu.html"/>
<jsp:useBean id="checkout" scope="page"
class="com.shop.CheckOut" />
<% if (checkout.ifTransactionComplete()) { %>
<jsp:forward page="confirmpurchase.jsp" />
<% } %>
<jsp:include file="checkout.html"/>
</body>
</html>
Assume that the sample sales JSP page above for an e-commerce store is
syntactically correct. Why does the page sometimes result in an
IllegalStateException being thrown?
One of the relative URLs does not exist.
Choice 1
Choice 2
The jsp:forward only works if the JSP buffer has been flushed prior to the
jsp:forward call.
The sample JSP page is not thread safe.
Choice 3
Submit
Which one of the following implicit objects is used to determine the scope
of a given object or attribute?
response
Choice 1
application
Choice 2
pageContext
Choice 3
config
Choice 4
session
Choice 5
Submit
pagecontext
Choice 2
exception
Choice 3
response
Choice 4
config
Choice 5
Submit
How do you include a file in your JSP file that you do NOT know the
filename of until runtime?
<%jsp:include file="prompt user"%>
Choice 1
<%@jsp:include page="null"%>
Choice 3
<%include page="null"%>
Choice 5
Submit
From a Web Application that has been deployed via a Web Archive (WAR)
file, how can files from the WEB-INF directory be retrieved?
servletContext.getResource()
Choice 1
<jsp:include file="/WEB-INF/file"/>
Choice 3
Choice 4
Choice 5
Submit
Problem
Your JSP file compiles just fine; however, you always get a
NoClassDefFoundError when you try to access a bean via the useBean
tag. All of the required files have been included on the CLASSPATH and
exist on the Web Server.
Why does the above problem occur?
You are using API 2.1 instead of API 2.2.
Choice 1
The useBean tag has not been defined from within the script.
Choice 2
All of the .class files have not been sent to the Web Server.
Choice 4
Submit
jspInit()
Choice 2
_jspRemove()
Choice 3
jspRestore()
Choice 4
jspDestroy()
Choice 5
Submit
Sample
Code
<%!
line 1: String nameSake;
Line 2: int count = 0;
Line 3: String rollUp = count + " " + nameSake;
Line 4: synchronized void doItAgain() {}
Line 5: int getCount() { return count; }
Line 6: float amount = 1.00f;
%>
Which one of the lines above causes a compile-time error?
Line 2
Choice 1
Line 3
Choice 2
Line 4
Choice 3
Line 5
Choice 4
Submit
Which implicit object is used to determine the real path to a resource on the
Web Server?
session
Choice 1
config
Choice 2
pageContext
Choice 3
request
Choice 4
application
Choice 5
Submit
session.setMaxInactiveInterval(10*60)
Choice 2
session.setMaxInactivePeriod(10*60)
Choice 3
session.setMaxInactivePeriod(10)
Choice 4
sessionContext.setMaxIdleTime(10*60)
Choice 5
Submit
Sample
Code
<%!
int counter = 0;
%>
<%
boolean flag = false;
counter++;
if(counter > 3) {
%>
Counter is greater than three
(<%= new Integer(counter).toString() %>)!
<%
}
else {
counter++;
%>
Counter is still less than three
(<%= new Integer(counter).toString() %>)!
<%
}
%>
What is the output of the above JSP the second time the document is
accessed?
Counter is still less than three. (1)
Choice 1
Submit
Scenario
In a banking Web Application, a customer can view his or her current bank
details and transfer money between accounts. When a user logs on, a
BankSession bean is added to the JSP Session Scope. When the user logs
out, the BankSession bean is removed from the JSP Session Scope.
During system testing, it has been discovered that the BankSession bean
does not close cleanly the moment the user's session times out. However,
this problem does not exist if the user disconnects cleanly.
Given the above scenario, what can be done to solve this?
Implement BankSession.release()
Choice 1
Implement HttpSessionBindingListener
Choice 2
Implement BankSession.finalize()
Choice 3
Implement JspSessionListener
Choice 4
Implement JspScopeListener
Choice 5
Submit
Information
Choice 1
Nothing, the JSP Engine handles all of these issues for all custom Tags.
Choice 3
Implement a TagPoolListener.
Choice 4
Submit
Which one of the following code segments is sent to the browser exactly as
is?
<%= "this is a comment" %>
Choice 1
Submit
Sample
Code
<%!
HashMap users2resource = new HashMap();
%>
<% HashMap people = new HashMap() %>
<% users2resource.put(..) %>
<% int j;
j = j+1; %>
.
.
.
<%= users2resource.get(..) %>
What potential problem, if any, exists for the sample JSP page above?
j = j+1 is not atomic.
Choice 1
There is no problem.
Choice 3
Submit
Submit
Choice 1
Choice 2
Which one of the following describes the benefit of using a <jsp:plugin />
tag?
It ensures that the client-side program will be loaded from the browser
every time it is executed.
It ensures that the correct HTML tag is placed in the output for the given
browser.
It allows internationalization features of the scripting language to be used.
Choice 3
Choice 4
Choice 5
Submit
It avoids the need for signed code when serving applets or other client-side
programs.
It reduces the size of a JSP that includes applets or other client-side
programs.
Java Server Pages (JSP 1.1), Question 19 of 40
Sample
Code
<%
<%
String there = "there";
out.println(myStr + " " + there);
int count = 1;
%>
<%
for(int i=0;i<10;i++) out.println(++count);
%>
When the JSP code above is translated, how are the variables defined in
different scriptlets made available to the other scriptlets?
All scriptlet variables are defined as class variables.
Choice 1
The variables are not available across scriptlets, and a translation error will
occur.
All scriptlet code becomes part of the same method.
Choice 5
Submit
javax.servlet.jsp.tagext.Tag OR
javax.servlet.jsp.tagext.BodyTag
Only javax.servlet.jsp.JspPage
Choice 3
Only javax.servlet.jsp.tagext.Tag
Choice 4
Choice 5
Submit
javax.servlet.jsp.tagext.TagSupport OR
javax.servlet.jsp.tagext.BodyTagSupport
Java Server Pages (JSP 1.1), Question 21 of 40
Sample
Code
Choice 1
Only before any scriptlets that write output to the Response object
Choice 5
Submit
Image
ASP
Choice 2
HTML
Choice 3
TLD
Choice 4
PHP
Choice 5
Submit
jspEngine.getTags()
Choice 2
tagSupport.getTags()
Choice 3
tagLibraryContext.getTags()
Choice 4
tagLibraryInfo.getTags()
Choice 5
Submit
Image
The diagram above shows the Server process of creating and running JSP
Servlets. One of the steps has been blanked out with XXX. Which one of
the following correctly describes this step?
JSP Page Changed
Choice 1
Beans Valid
Choice 2
Database Active
Choice 3
Submit
Information
Choice 1
A security policy domain is a scope over which security policies are defined
and enforced by a security administrator.
Based on the information above, which one of the following is NOT a
characteristic of a security policy domain upon which a JSP can run?
The security policy ensures that multiple security policy domains can exist
within a single technology domain.
The security policy may have groups to simplify setting of security policies.
Choice 2
Submit
A _httpService method
Choice 2
A _jspService method
Choice 3
A class
Choice 4
A static method
Choice 5
Submit
Context
Choice 1
Choice 2
Choice 3
Choice 4
Choice 5
Submit
Sample
Code
Choice 1
1
Choice 2
2
Choice 3
4
Choice 4
5
Choice 5
Submit
Which one of the following URLs can be used inside a <jsp:include />
statement?
http://www.xyz.com/code/tt.jsp
Choice 1
http://www.xyz.com/jsp
Choice 2
/f1/temp1.jsp
Choice 3
ftp://ftp.xyz.com/dir1/temp1.jsp
Choice 4
https://www.xyz.com
Choice 5
Submit
Sample
Code
Choice 1
pageContext.getJspProperty()
Choice 2
pageContext.getInfo()
Choice 3
page.getServletInfo()
Choice 4
page.getPageInfo()
Choice 5
Submit
Sample
Code
Choice 1
Start=5
Choice 2
Start=6
Choice 3
Submit
When implementing a new custom tag, what is the role of a Tag Extra Info
(TEI) class?
Only to store meta information about the Tag
Choice 1
Choice 2
Choice 3
To add extra validation to the custom tag and to declare new scripting
variables introduced by the Tag
To store meta information about the Tag and to add extra validation to the
custom tag
Only to add extra validation to the custom tag
Choice 4
Submit
How can a custom tag introduce new scripting variables into a JSP page?
Implement getVariableInfo() on a TagExtraInfo class
Choice 1
Choice 2
Choice 3
Submit
Sample
Code
Choice 1
response.encodeURL()
Choice 2
response.getCharacterEncoding()
Choice 3
response.getOutputStream()
Choice 4
response.addCookie()
Choice 5
Submit
What object or scriptlet code inside a JSP returns a reference to the JSP's
javax.servlet.ServletContext object?
page.getContext()
Choice 1
request.getServletContext()
Choice 2
application
Choice 3
config.getContext()
Choice 4
context
Choice 5
Submit
Macros
Choice 3
New actions
Choice 5
Submit
Submit
Sample
Code
Choice 1
init method
Choice 2
doGet method
Choice 3
doPost method
Choice 4
service method
Choice 5
Submit
Image
The flow diagram above describes the live cycle of a BodyTag, but it is
missing a label. Which one of the following correctly describes what
happens at XXX?
doBeforeTag
Choice 1
Clear Buffer
Choice 2
Set Attributes
Choice 4
Submit