You are on page 1of 41

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? JSP pages use a different Streaming mechanism to Servlets. JSP pages can write a Binary Stream using its implicit out stream.

Choice 1 Choice 2 Choice 3 Choice 4

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. JSP has already opened the stream as a JspWriter.

Choice 5

Submit

Java Server Pages (JSP 1.1), Question 1 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

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

Java Server Pages (JSP 1.1), Question 2 of 40

Take a 15 minute break AFTER this question (one per test)

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 Choice 3

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. The jsp:forward cannot be called after jsp:include.

Choice 4

The jsp:useBean tag must be declared at the top of the file.


Choice 5

Submit

Java Server Pages (JSP 1.1), Question 3 of 40

Take a 15 minute break AFTER this question (one per test)


1998 - 2002 Brainbench, Inc. All rights reserved.

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

Java Server Pages (JSP 1.1), Question 4 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

Which implicit object represents a java.lang.Throwable object? error


Choice 1

pagecontext
Choice 2

exception
Choice 3

response
Choice 4

config
Choice 5

Submit

Java Server Pages (JSP 1.1), Question 5 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

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

<%@include file="<%= filename %>"%>


Choice 2

<%@jsp:include page="null"%>
Choice 3

<jsp:include page="<%= filename %>">


Choice 4

<%include page="null"%>
Choice 5

Submit

Java Server Pages (JSP 1.1), Question 6 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

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

<%@ include file="/WEB-INF/file"/%>


Choice 2

<jsp:include file="/WEB-INF/file"/>
Choice 3 Choice 4 Choice 5

From a Web browser, request http://domain/appname/WEBINF/file new FileOutputStream(new File("/WEB-INF/file")) Java Server Pages (JSP 1.1), Question 7 of 40

Submit

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

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

The client browser is not using Java 1.1.1.


Choice 3

All of the .class files have not been sent to the Web Server.
Choice 4

Your beans do not belong to the package.


Choice 5

Submit

Java Server Pages (JSP 1.1), Question 8 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

Which one of the following JSP lifecycle methods CANNOT be defined within a JSP page? _jspService()
Choice 1

jspInit()
Choice 2

_jspRemove()
Choice 3

jspRestore()
Choice 4

jspDestroy()
Choice 5

Submit

Java Server Pages (JSP 1.1), Question 9 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

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

Code will compile.


Choice 5

Submit

Java Server Pages (JSP 1.1), Question 10 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

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

Java Server Pages (JSP 1.1), Question 11 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

Which one of the following commands causes a JSP session to be automatically closed after the user has been inactive for 10 minutes? response.setExpirePeriod(10*60)
Choice 1

session.setMaxInactiveInterval(10*60)
Choice 2

session.setMaxInactivePeriod(10*60)
Choice 3

session.setMaxInactivePeriod(10)
Choice 4

sessionContext.setMaxIdleTime(10*60)
Choice 5

Submit

Java Server Pages (JSP 1.1), Question 12 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

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) Counter is still less than three. (2)

Choice 1 Choice 2

Counter is still less than three. (4)


Choice 3

Counter is greater than three. (4)


Choice 4

An IllegalStateException will be thrown.


Choice 5

Submit

Java Server Pages (JSP 1.1), Question 13 of 40

Take a 15 minute break AFTER this question (one per test)


1998 - 2002 Brainbench, Inc. All rights reserved.

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

Java Server Pages (JSP 1.1), Question 14 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

Information

As a performance optimization, some JSP Engines reuse the Java instances of a Custom Tag. Given that some JSP Engines have the above optimization, what can be done by authors of custom tag libraries to prevent the data integrity of the tag handlers from being corrupted? Implement a cleanup finalize() method. Each tag should synchronize on a lock object.

Choice 1 Choice 2

Nothing, the JSP Engine handles all of these issues for all custom Tags.
Choice 3

Implement a TagPoolListener.
Choice 4

Implement a cleanup release() method.


Choice 5

Submit

Java Server Pages (JSP 1.1), Question 15 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

Which one of the following code segments is sent to the browser exactly as is? <%= "this is a comment" %>
Choice 1

<% String comment="this is a comment" %>


Choice 2

<!-- "this is a comment" -->


Choice 3

<%@ page comment="this is a comment" %>


Choice 4

<%-- "this is a comment" --%>


Choice 5

Submit

Java Server Pages (JSP 1.1), Question 16 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

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

The users2resource is not thread safe.


Choice 2

There is no problem.
Choice 3

The people is not thread safe.


Choice 4

The resources put into people will never be garbage collected.


Choice 5

Submit

Java Server Pages (JSP 1.1), Question 17 of 40

Take a 15 minute break AFTER this question (one per test)


1998 - 2002 Brainbench, Inc. All rights reserved.

What is the implication of using cookies to track sessions when a user opens multiple browser windows? Neither browser will share the same session ID.
Choice 1

They will both share the same session ID.


Choice 2

It does not list any entries in the session logs.


Choice 3

Duplicate entries in the session logs will occur.


Choice 4

The page cannot be bookmarked.


Choice 5

Submit

Java Server Pages (JSP 1.1), Question 18 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

Choice 1 Choice 2 Choice 3 Choice 4 Choice 5

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. 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

Submit

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

Sample Code

<% <%

String myStr = "Hello"; %> 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 translator copies all variables to each scriptlet before compiling.


Choice 2

All scriptlet variables are defined with "page" level scope.


Choice 3 Choice 4 Choice 5

The variables are not available across scriptlets, and a translation error will occur. All scriptlet code becomes part of the same method. Java Server Pages (JSP 1.1), Question 20 of 40

Submit

Take a 15 minute break AFTER this question (one per test)


1998 - 2002 Brainbench, Inc. All rights reserved.

A tag handler object is a Java object that implements what interface? Only javax.servlet.jsp.tagext.BodyTag
Choice 1 Choice 2 Choice 3

javax.servlet.jsp.tagext.Tag OR javax.servlet.jsp.tagext.BodyTag Only javax.servlet.jsp.JspPage Only javax.servlet.jsp.tagext.Tag

Choice 4 Choice 5

javax.servlet.jsp.tagext.TagSupport OR javax.servlet.jsp.tagext.BodyTagSupport Java Server Pages (JSP 1.1), Question 21 of 40

Submit

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

Sample Code

<jsp:forward page="eBusiness.jsp" /> Within a JSP document, where can the above code appear, given that the JspWriter's buffer will NOT be flushed until the end of the JSP page has been reached? Anywhere within the document

Choice 1

Only before any directives


Choice 2

Only on the very first line of the document


Choice 3

Only before any declarations


Choice 4

Only before any scriptlets that write output to the Response object
Choice 5

Submit

Java Server Pages (JSP 1.1), Question 22 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

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? JSP
Choice 1

ASP
Choice 2

HTML
Choice 3

TLD
Choice 4

PHP
Choice 5

Submit

Java Server Pages (JSP 1.1), Question 23 of 40

Take a 15 minute break AFTER this question (one per test)


1998 - 2002 Brainbench, Inc. All rights reserved.

How is it possible to programmatically retrieve a list of custom tags supported by a tag library? tldInfo.getTags()
Choice 1

jspEngine.getTags()
Choice 2

tagSupport.getTags()
Choice 3

tagLibraryContext.getTags()
Choice 4

tagLibraryInfo.getTags()
Choice 5

Submit

Java Server Pages (JSP 1.1), Question 24 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

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

JSP Engine Active


Choice 4

JSP Page pre-compiled


Choice 5

Submit

Java Server Pages (JSP 1.1), Question 25 of 40

Take a 15 minute break AFTER this question (one per test)


1998 - 2002 Brainbench, Inc. All rights reserved.

Information

Choice 1 Choice 2

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. The security policy has a collection of users or principals.

Choice 3 Choice 4 Choice 5

The security policy uses a well-defined authentication protocol(s) for authenticating users. The security policy contains an object that encapsulates single state information between two entities. Java Server Pages (JSP 1.1), Question 26 of 40

Submit

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

Which one of the following CANNOT be defined inside a JSP page? A class method
Choice 1

A _httpService method
Choice 2

A _jspService method
Choice 3

A class
Choice 4

A static method
Choice 5

Submit

Java Server Pages (JSP 1.1), Question 27 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

Context

Choice 1 Choice 2 Choice 3 Choice 4 Choice 5

By default, a client has access to all of a Bean's properties. Given the above context, how can you prevent a client from accessing sensitive Bean properties? Use a firewall or a proxy to discourage data from being sent back to the client browser. Mark sensitive Bean attributes as "Read-Only" in BeanInfo PropertyDescriptors. Do not place the Bean in the root or virtual root directory. Use a shadow Bean, also known as a proxy Bean, to set non-sensitive Bean properties. Avoid revealing the name of sensitive properties by not using Bean aliases. Java Server Pages (JSP 1.1), Question 28 of 40

Submit

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

Sample Code

<jsp:useBean id="ww" scope="page" class="Ww.class" /> How many instances of the "Ww.class" are created in the JSP engine after the JSP containing the above code is accessed five times? 0

Choice 1

1
Choice 2

2
Choice 3

4
Choice 4

5
Choice 5

Submit

Java Server Pages (JSP 1.1), Question 29 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

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

Java Server Pages (JSP 1.1), Question 30 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

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? page.getJspInfo()

Choice 1

pageContext.getJspProperty()
Choice 2

pageContext.getInfo()
Choice 3

page.getServletInfo()
Choice 4

page.getPageInfo()
Choice 5

Submit

Java Server Pages (JSP 1.1), Question 31 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

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? Start=0 Start=5

Choice 1 Choice 2

Start=6
Choice 3

The JSP page throws an exception.


Choice 4

It could be anything; the page is not thread safe.


Choice 5

Submit

Java Server Pages (JSP 1.1), Question 32 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

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 Choice 4

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 Only to declare new scripting variables introduced by the Tag

Choice 5

Submit

Java Server Pages (JSP 1.1), Question 33 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

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

Add <scripting-variable>..</scripting-variable> to the tag's Tag Library Descriptor (TLD) entry Implement a new TagAttributeInfo for each new Scripting Variable Implement getScriptingVariables on a TagInfo class

Choice 4

Implement getScriptingVariables to the tag's class implementation


Choice 5

Submit

Java Server Pages (JSP 1.1), Question 34 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

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"? response.getWriter()

Choice 1

response.encodeURL()
Choice 2

response.getCharacterEncoding()
Choice 3

response.getOutputStream()
Choice 4

response.addCookie()
Choice 5

Submit

Java Server Pages (JSP 1.1), Question 35 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

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

Java Server Pages (JSP 1.1), Question 36 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

As stated in the JSP1.1 specification, what do Custom Tag Libraries offer to Web Developers? Ability to distribute processing
Choice 1

Dynamic modification of the browser


Choice 2

Macros
Choice 3

Compile time checking


Choice 4

New actions
Choice 5

Submit

Java Server Pages (JSP 1.1), Question 37 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

Which one of the following code segments sends a string of "Hello" STRAIGHT to the requesting client? <% out.print("Hello"); %>
Choice 1

<%@ output value="Hello" %>


Choice 2

<%= "Hello" %>


Choice 3

<% System.out.println("Hello"); %>


Choice 4

<%! "Hello" %>


Choice 5

Submit

Java Server Pages (JSP 1.1), Question 38 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

Sample Code

<%! String t1="hello"; %> When the declaration above is made in a JSP, in which method is the String object "t1" declared? Not in any method

Choice 1

init method
Choice 2

doGet method
Choice 3

doPost method
Choice 4

service method
Choice 5

Submit

Java Server Pages (JSP 1.1), Question 39 of 40

Take a 15 minute break AFTER this question (one per test)

1998 - 2002 Brainbench, Inc. All rights reserved.

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

Read in Tag's Body


Choice 3

Set Attributes
Choice 4

Initialize Tag's Body


Choice 5

Submit

Java Server Pages (JSP 1.1), Question 40 of 40

Take a 15 minute break AFTER this question (one per test)


1998 - 2002 Brainbench, Inc. All rights reserved.

Congratulations! You passed at the Master's Level with a score of 4.21. You have now earned a Master certification in Java Server Pages (JSP 1.1).
Your Transcript ID Number is 3025842

You might also like