Hi all ,
just cleared jsp exam on brainbench
Hope this will help all,
The majority of the integration of JSP pages within the J2EE platform is
inherited from the reliance on what specification?
Choice 1
Servlet 2.2
Choice 2
EJB 1.1
Choice 3
JSP 1.1
Choice 4
HTTP 4.0
Choice 5
JNDI
Java Server Pages (JSP 1.1), Question 40 of 40
his question (one per test)
Scenario
A banking application has been written that stores current context in a
Sessionlevel bean. The typical data stored in the context is the current
user name and current account being viewed.
Referring to the above scenario, what defect does this application suffer
from because of how it is using the Sessionlevel bean?
Choice 1
If the user does not log out, then the information stored in the context
will remain in the Web Server until the user next logs on.
Choice 2
Storing information in this way may open a security hole that allows
hackers to retrieve user information very easily.
Choice 3
The information concerning the account the customer is viewing because the
account number is not stored in the Requestlevel bean.
Choice 4
Storing this information on the Web Server is likely to increase the burden
on the Web Server, damaging performance.
Choice 5
Use of a Web browser's Back button could cause operations to be carried out
against the wrong account.
Java Server Pages (JSP 1.1), Question 39 of 40
his question (one per test)
Sample TLD
<rtexprvalue>false</rtexprvalue>
In a Tag Library Descriptor (TLD) file, what does the above tag mean when
applied to a tag's attribute?
Choice 1
The attribute is now an enumeration it can be set to one of a fixed number
of possible values.
Choice 2
The attribute's value may be set with a <%= .. %> tag.
Choice 3
The attribute may not be dynamically set.
Choice 4
The attribute can no longer be used it has been depreciated.
Choice 5
The attribute will take its value from a Java Bean.
Java Server Pages (JSP 1.1), Question 38 of 40
his question (one per test)
Sample Code
<jsp:include page="second.jsp" flush="true" />
Using the code fragment shown above, which one of the following methods
causes an exception to be thrown if called by code in "second.jsp"?
Choice 1
response.getOutputStream()
Choice 2
response.addCookie()
Choice 3
response.encodeURL()
Choice 4
response.getCharacterEncoding()
Choice 5
response.getWriter()
Java Server Pages (JSP 1.1), Question 37 of 40
his question (one per test)
Sample TLD
<tag>
<name>pp</name>
<tagclass>com.pp</tagclass>
<bodycontent>empty</bodycontent>
<attribute>
<name>t</name>
<required>true</required>
</attribute>
</tag>
Given the above snippet from a Tag Library Descriptor (TLD), which one of
the following tags does it describe?
Choice 1
<t pp="h"/>
Choice 2
<pp t="w"/>
Choice 3
<pp t="e">
Choice 4
<t>
Choice 5
<pp></pp>
Java Server Pages (JSP 1.1), Question 36 of 40
his question (one per test)
Sample Code
<%! int start = 0; %>
<% start += 1;%>
Start=<%= start %>
After the above JSP has been accessed five times, what is the output on
the sixth access?
Choice 1
Start=0
Choice 2
Start=5
Choice 3
Start=6
Choice 4
The JSP page throws an exception.
Choice 5
It could be anything; the page is not thread safe.
Java Server Pages (JSP 1.1), Question 35 of 40
his question (one per test)
Image
Given the above diagram, the Model 2 architecture is an adaptation of the
Model View Controller (MVC) paradigm for Web sites that use JSP pages. Which
one of the following technologies is an INCORRECT choice for the
visualization component?
Choice 1
HTML
Choice 2
TLD
Choice 3
ASP
Choice 4
PHP
Choice 5
JSP
Java Server Pages (JSP 1.1), Question 34 of 40
his question (one per test)
When building a Web Archive (WAR) target for a Web Application,
supporting class files are placed in which one of the following directories?
Choice 1
/classes
Choice 2
/WEBINF/classes
Choice 3
/WEBINF/lib
Choice 4
/WEBINF
Choice 5
/xml
Java Server Pages (JSP 1.1), Question 33 of 40
his question (one per test)
Sample Code
<%@ page info="Here is the info you requested." %>
Which one of the following methods is used to access the page information
embedded in the directive above within a JSP?
Choice 1
page.getJspInfo()
Choice 2
page.getServletInfo()
Choice 3
page.getPageInfo()
Choice 4
pageContext.getInfo()
Choice 5
pageContext.getJspProperty()
Java Server Pages (JSP 1.1), Question 32 of 40
his question (one per test)
Which one of the following approaches ensures that a JSP page that
includes "page2.html" always shows the most uptodate version of the included
page?
Choice 1
<jsp:forward page="page2.html" />
Choice 2
<jsp:include page="page2.html" />
Choice 3
<jsp:usebean file="page2.html" />
Choice 4
<%@ jsp:include file="page2.html" flush="true" %>
Choice 5
<%@ include file="page2.html" %>
Java Server Pages (JSP 1.1), Question 31 of 40
his question (one per test)
Scenario
You are nearing the end of a tight deadline, but the JSP page performance
is still too slow.
Given the above scenario and that you have LIMITED time, which one of the
following standard techniques do you use to gain a substantial JSPDB
performance gain?
Choice 1
Cache query data in the Web Server
Choice 2
Offload page processing to client browsers
Choice 3
Move the database onto the same machine as the Web Server
Choice 4
Implement a Connection Pool
Choice 5
Add more Web Servers
Java Server Pages (JSP 1.1), Question 30 of 40
his question (one per test)
Steps
A) Add a Tag Library Directive to the JSP pages
B) Implement a Tag Handler Class
C) Write a Tag Library Descriptor (TLD) File
D) Write a Servlet to process the Custom Tag
E) Write in Java validation rules for the Tag's attributes
Referring to the above steps, what steps must be performed in order to
write and deploy a Custom Tag Library? (Note: Order does NOT matter)
Choice 1
A, B, and C
Choice 2
A, B, and E
Choice 3
B and C
Choice 4
B, C, and E
Choice 5
C and E
Java Server Pages (JSP 1.1), Question 29 of 40
his question (one per test)
What object or scriptlet code inside a JSP returns a reference to the
JSP's javax.servlet.ServletContext object?
Choice 1
context
Choice 2
application
Choice 3
page.getContext()
Choice 4
config.getContext()
Choice 5
request.getServletContext()
Java Server Pages (JSP 1.1), Question 28 of 40
his question (one per test)
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?
Choice 1
javax.servlet.jsp.tagext.TagData
Choice 2
javax.servlet.jsp.tagext.Tag
Choice 3
javax.servlet.jsp.tagext.BodyTagSupport
Choice 4
javax.servlet.jsp.tagext.TagBody
Choice 5
javax.servlet.jsp.tagext.BodyTag
Java Server Pages (JSP 1.1), Question 27 of 40
his question (one per test)
Which one of the following classes is always available to a JSP page as
an applicationlevel implicit object?
Choice 1
javax.servlet.ServletRequest
Choice 2
javax.servlet.ServletContext
Choice 3
java.lang.Throwable
Choice 4
javax.servlet.ServletResponse
Choice 5
javax.servlet.ServletConfig
Java Server Pages (JSP 1.1), Question 26 of 40
his question (one per test)
Which one of the following classes is always available to a JSP page as
an applicationlevel implicit object?
Choice 1
javax.servlet.ServletRequest
Choice 2
javax.servlet.ServletContext
Choice 3
java.lang.Throwable
Choice 4
javax.servlet.ServletResponse
Choice 5
javax.servlet.ServletConfig
Java Server Pages (JSP 1.1), Question 26 of 40
his question (one per test)
Scenario
A Web Application written using JSP pages makes use of Wizardstyle
walkthroughs to aid users whenever they make complicated changes. A change
to the ordering of each JSP page in the Wizard takes over 3 hours to
complete. This is unacceptable for such a trivial and common operation.
Given the above scenario, what is a possible approach for reducing the
time taken to change the ordering of pages?
Choice 1
Implement the JSP pages using a templating scheme.
Choice 2
Do not share JSP pages between Wizards.
Choice 3
Use a Servlet to abstract the difference between page control and page
visualization.
Choice 4
Implement the JSP pages with more embedded scriptlets designed to make page
ordering easier to change.
Choice 5
Implement the JSP pages using a Model 1 architecture.
Java Server Pages (JSP 1.1), Question 25 of 40
his question (one per test)
Statement
A JSP page is compiled into a Servlet; therefore, it can do everything that
a Servlet can do.
If the above statement is TRUE, then why is an IllegalStateException
thrown when opening a Binary Stream output to the client from a JSP page but
NOT to a Servlet?
Choice 1
JSP pages can write a Binary Stream using its implicit out stream.
Choice 2
JSP pages use a different Streaming mechanism to Servlets.
Choice 3
JSP pages must flush their buffers before changing the stream type;
Servlets do not have this limitation.
Choice 4
JSP pages have more security settings than Servlets.
Choice 5
JSP has already opened the stream as a JspWriter.
Java Server Pages (JSP 1.1), Question 24 of 40
his question (one per test)
Which one of the following methods sends the HTTP HEADER values to the
client browser WITHOUT stopping the JSP page?
Choice 1
out.flush()
Choice 2
out.close()
Choice 3
response.release()
Choice 4
response.sendheaders()
Choice 5
response.flushheaders()
Java Server Pages (JSP 1.1), Question 23 of 40
his question (one per test)
When a custom tag implements the BodyTag Interface, how does the JSP
Engine handle nested tags?
Choice 1
The contents of the nested tags are sent to the browser in a breadth first
traversal of the nested hierarchy.
Choice 2
The output of a nested tag is sent to a buffer that the parent tag can see.
Choice 3
It is the responsibility of the nested tag to pass information to its
parent tag.
Choice 4
The contents of the nested tags are sent to the browser in a depth first
traversal of the nested hierarchy.
Choice 5
JSP does not support nested tags.
Java Server Pages (JSP 1.1), Question 22 of 40
his question (one per test)
Which one of the following is a valid argument for a JSP page directive?
Choice 1
extender="package.class"
Choice 2
contentType="text/html"
Choice 3
isThreadSafe="yes|no"
Choice 4
importer="package.class"
Choice 5
caching="sizekb|none"
Java Server Pages (JSP 1.1), Question 21 of 40
his question (one per test)
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?
Choice 1
Implement JspScopeListener
Choice 2
Implement HttpSessionBindingListener
Choice 3
Implement BankSession.release()
Choice 4
Implement BankSession.finalize()
Choice 5
Implement JspSessionListener
Java Server Pages (JSP 1.1), Question 20 of 40
his question (one per test)
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?
Choice 1
Implement JspSessionListener
Choice 2
Implement BankSession.finalize()
Choice 3
Implement JspScopeListener
Choice 4
Implement BankSession.release()
Choice 5
Implement HttpSessionBindingListener
Java Server Pages (JSP 1.1), Question 20 of 40
his question (one per test)
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?
Choice 1
Implement JspSessionListener
Choice 2
Implement BankSession.finalize()
Choice 3
Implement JspScopeListener
Choice 4
Implement BankSession.release()
Choice 5
Implement HttpSessionBindingListener
Java Server Pages (JSP 1.1), Question 20 of 40
his question (one per test)
Which one of the following code segments correctly declares a method that
increments static int x by one?
Choice 1
<%@ static void increment()
x++;
} />
Choice 2
<% public void increment()
x++;
} %>
Choice 3
<% x++; %>
Choice 4
<%@ method void increment()
x++;
} %>
Choice 5
<%! public void increment()
x++;
} %>
Java Server Pages (JSP 1.1), Question 18 of 40
his question (one per test)
Which tag or tags give you a reference to a Servlet of class
servlets.MyServlet?
Choice 1
<jsp:useBean id="myref" scope="session" class="MyServlet" />
Choice 2
<%@ include file="servlets/MyServlet.class" %>
Choice 3
<%@ page import="servlets.*" %>
<jsp:getProperty name="MyServlet" />
Choice 4
<jsp:useBean id="myref" class="servlets.MyServlet" />
Choice 5
<jsp:include class="servlets.MyServlet" flush="true" />
Java Server Pages (JSP 1.1), Question 17 of 40
his question (one per test)
Which one of the following URLs can be used inside a <jsp:include />
statement?
Choice 1
http://www.xyz.com/code/tt.jsp
Choice 2
/f1/temp1.jsp
Choice 3
https://www.xyz.com
Choice 4
http://www.xyz.com/jsp
Choice 5
ftp://ftp.xyz.com/dir1/temp1.jsp
Java Server Pages (JSP 1.1), Question 16 of 40
his question (one per test)
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?
Choice 1
The users2resource is not thread safe.
Choice 2
The resources put into people will never be garbage collected.
Choice 3
The people is not thread safe.
Choice 4
There is no problem.
Choice 5
j = j+1 is not atomic.
Java Server Pages (JSP 1.1), Question 15 of 40
his question (one per test)
How is it possible to programmatically retrieve a list of custom tags
supported by a tag library?
Choice 1
tagSupport.getTags()
Choice 2
tldInfo.getTags()
Choice 3
tagLibraryContext.getTags()
Choice 4
tagLibraryInfo.getTags()
Choice 5
jspEngine.getTags()
Java Server Pages (JSP 1.1), Question 14 of 40
his question (one per test)
What effect on variables does the keyword "static" have when used in the
declaration section of a JSP page?
Choice 1
The static keyword is ignored when used within the declaration section.
Choice 2
Static cannot be used because it is a serverassigned keyword and will throw
an exception error.
Choice 3
Its value is shared by all instances of the class.
Choice 4
Static is similar to declaring an include variable in the declaration
section.
Choice 5
Static must be assigned as a variable within an array before use.
Java Server Pages (JSP 1.1), Question 13 of 40
his question (one per test)
Sample Code
{
String s="X";
int i=Integer.parseInt(s);
}
catch(NumberFormatException ex){
System.out.println(s + " can't be converted to an int");
return;
}
finally{
System.out.println("The sky is blue.");
}
In the above code fragment, when does the "finally" exception handler execute?
Choice 1
After NumberFormatException has been thrown
Choice 2
When int=I is a string
Choice 3
When String=S is equal to X
Choice 4
Always
Choice 5
When in
t=I is equal to a number above zero
Java Server Pages (JSP 1.1), Question 12 of 40
his question (one per test)
Which one of the following codes within a JSP document forces the derived
Servlet to implement the "myclasses.Connectit" interface?
Choice 1
<%@ interface name="myclasses.Connectit" %>
Choice 2
It is not possible to implement an interface in JSPs.
Choice 3
<%@ page extends="myclasses.Connectit" %>
Choice 4
<%@ page interface="myclasses.Connectit" %>
Choice 5
<%@ page implements="myclasses.Connectit" %>
Java Server Pages (JSP 1.1), Question 11 of 40
his question (one per test)
Steps
A) Run files through a WAR file utility
B) Archive files and directories with a JAR utility
C) Add a WEBINF directory to the site
D) Store configuration information in METAINF
E) Write a web.xml file
F) Write a configuration file for each supported Web Server
Which of the above steps MUST be followed to produce a Web Archive (WAR)
file? (Note: Order does NOT matter)
Choice 1
A, B, E
Choice 2
A, C, E
Choice 3
A, D, F
Choice 4
B, C, E
Choice 5
B, E, F
Java Server Pages (JSP 1.1), Question 10 of 40
his question (one per test)
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?
Choice 1
Your beans do not belong to the package.
Choice 2
All of the .class files have not been sent to the Web Server.
Choice 3
The client browser is not using Java 1.1.1.
Choice 4
You are using API 2.1 instead of API 2.2.
Choice 5
The useBean tag has not been defined from within the script.
Java Server Pages (JSP 1.1), Question 9 of 40
his question (one per test)
Which one of the following implicit objects is used to determine the
scope of a given object or attribute?
Choice 1
config
Choice 2
application
Choice 3
response
Choice 4
session
Choice 5
pageContext
Java Server Pages (JSP 1.1), Question 8 of 40
his question (one per test)
Which implicit object is used to determine the real path to a resource on
the Web Server?
Choice 1
application
Choice 2
session
Choice 3
config
Choice 4
request
Choice 5
pageContext
Java Server Pages (JSP 1.1), Question 7 of 40
his question (one per test)
When a class is generated by a JSP engine, which interface must be
satisfied for use with the HTTP protocol?
Choice 1
HttpJspPage
Choice 2
HttpJspServlet
Choice 3
Servlet
Choice 4
JspPage
Choice 5
JspServlet
Java Server Pages (JSP 1.1), Question 6 of 40
his question (one per test)
Sample Code
1) final int MAX_COUNT = 9;
2) static int MAX_COUNT = 9;
3) int MAX_COUNT;
4) synchronized void doIt() { x++; }
5) public void doIt() { x++; }
Which line(s) of the above code fragments can appear inside a <% .. %>
SCRIPTLET?
Choice 1
Lines 1 and 2
Choice 2
Lines 1 and 3
Choice 3
Lines 2 and 5
Choice 4
Only Line 4
Choice 5
Only Line 5
Java Server Pages (JSP 1.1), Question 5 of 40
his question (one per test)
How can you set up a cookie to expire after a certain time?
Choice 1
updateMaxAge(int seconds)
Choice 2
setMaxAge(int seconds)
Choice 3
updateMinAge/MaxAge(int seconds)
Choice 4
setMinAge/MaxAge (TTL)
Choice 5
expire.MaxAge(int seconds)
Java Server Pages (JSP 1.1), Question 4 of 40
his question (one per test)
Which one of the following is NOT a valid property type that can be
assigned using jsp:setProperty?
Choice 1
Boolean
Choice 2
Byte
Choice 3
Float
Choice 4
Character
Choice 5
Date
Java Server Pages (JSP 1.1), Question 3 of 40
his question (one per test)
A tag handler object is a Java object that implements what interface?
Choice 1
Only javax.servlet.jsp.tagext.Tag
Choice 2
javax.servlet.jsp.tagext.TagSupport OR
javax.servlet.jsp.tagext.BodyTagSupport
Choice 3
Only javax.servlet.jsp.tagext.BodyTag
Choice 4
javax.servlet.jsp.tagext.Tag OR
javax.servlet.jsp.tagext.BodyTag
Choice 5
Only javax.servlet.jsp.JspPage
Java Server Pages (JSP 1.1), Question 2 of 40
his question (one per test)
Which scope level for the <jsp:useBean> tag is required for the object
reference to the bean to be placed in the page's ServletContext object?
Choice 1
page
Choice 2
session
Choice 3
request
Choice 4
application
Choice 5
server
Java Server Pages (JSP 1.1), Question 1 of 40
his question (one per test)
regards
MJ
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets