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

145400447 JSP Andris Birkmanis

Embed Size (px)

DESCRIPTION

Ebook

Citation preview

  • 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 use a different Streaming mechanism to Servlets.

    Choice 2 JSP pages can write a Binary Stream using its implicit out stream.

    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.

    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

    9+10*4/2+1

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

    Choice 2 javax.servlet.jsp.tagext.TagData

    Choice 3 javax.servlet.jsp.tagext.Tag

    Choice 4 javax.servlet.jsp.tagext.TagBody

    Choice 5 javax.servlet.jsp.tagext.BodyTagSupport

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

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

  • Sample Code

    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?

    Choice 1 One of the relative URLs does not exist.

    Choice 2 The jsp:forward only works if the JSP buffer has been flushed prior to the jsp:forward call.

    Choice 3 The sample JSP page is not thread safe.

    Choice 4 The jsp:forward cannot be called after jsp:include.

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

    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?

    Choice 1 response

    Choice 2 application

    Choice 3 pageContext

    Choice 4 config

    Choice 5 session

    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?

    Choice 1 error

    Choice 2 pagecontext

    Choice 3 exception

    Choice 4 response

    Choice 5 config

    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?

    Choice 1

    Choice 2

    Choice 3

    Choice 4

    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?

    Choice 1 servletContext.getResource()

    Choice 2

    Choice 3

    Choice 4 From a Web browser, request http://domain/appname/WEB-INF/file

    Choice 5 new FileOutputStream(new File("/WEB-INF/file"))

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

    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?

    Choice 1 You are using API 2.1 instead of API 2.2.

    Choice 2 The useBean tag has not been defined from within the script.

    Choice 3 The client browser is not using Java 1.1.1.

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

    Choice 5 Your beans do not belong to the package.

    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?

    Choice 1 _jspService()

    Choice 2 jspInit()

    Choice 3 _jspRemove()

    Choice 4 jspRestore()

    Choice 5 jspDestroy()

    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

    Which one of the lines above causes a compile-time error?

    Choice 1 Line 2

    Choice 2 Line 3

    Choice 3 Line 4

    Choice 4 Line 5

    Choice 5 Code will compile.

    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?

    Choice 1 session

    Choice 2 config

    Choice 3 pageContext

    Choice 4 request

    Choice 5 application

    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?

    Choice 1 response.setExpirePeriod(10*60)

    Choice 2 session.setMaxInactiveInterval(10*60)

    Choice 3 session.setMaxInactivePeriod(10*60)

    Choice 4 session.setMaxInactivePeriod(10)

    Choice 5 sessionContext.setMaxIdleTime(10*60)

    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

    3) { %> Counter is greater than three ()! Counter is still less than three ()! What is the output of the above JSP the second time the document is accessed?

    Choice 1 Counter is still less than three. (1)

    Choice 2 Counter is still less than three. (2)

    Choice 3 Counter is still less than three. (4)

    Choice 4 Counter is greater than three. (4)

    Choice 5 An IllegalStateException will be thrown.

    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?

    Choice 1 Implement BankSession.release()

    Choice 2 Implement HttpSessionBindingListener

    Choice 3 Implement BankSession.finalize()

    Choice 4 Implement JspSessionListener

    Choice 5 Implement JspScopeListener

    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?

    Choice 1 Implement a cleanup finalize() method.

    Choice 2 Each tag should synchronize on a lock object.

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

    Choice 4 Implement a TagPoolListener.

    Choice 5 Implement a cleanup release() method.

    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?

    Choice 1

    Choice 2

    Choice 3

    Choice 4

    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

    .

    .

    .

    What potential problem, if any, exists for the sample JSP page above?

    Choice 1 j = j+1 is not atomic.

    Choice 2 The users2resource is not thread safe.

    Choice 3 There is no problem.

    Choice 4 The people is not thread safe.

    Choice 5 The resources put into people will never be garbage collected.

    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?

    Choice 1 Neither browser will share the same session ID.

    Choice 2 They will both share the same session ID.

    Choice 3 It does not list any entries in the session logs.

    Choice 4 Duplicate entries in the session logs will occur.

    Choice 5 The page cannot be bookmarked.

    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.

  • Which one of the following describes the benefit of using a tag?

    Choice 1 It ensures that the client-side program will be loaded from the browser every time it is executed.

    Choice 2 It ensures that the correct HTML tag is placed in the output for the given browser.

    Choice 3 It allows internationalization features of the scripting language to be used.

    Choice 4 It avoids the need for signed code when serving applets or other client-side programs.

    Choice 5 It reduces the size of a JSP that includes applets or other client-side programs.

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

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

    1998 - 2002 Brainbench, Inc.All rights reserved.

  • Sample Code

  • A tag handler object is a Java object that implements what interface?

    Choice 1 Only javax.servlet.jsp.tagext.BodyTag

    Choice 2 javax.servlet.jsp.tagext.Tag OR javax.servlet.jsp.tagext.BodyTag

    Choice 3 Only javax.servlet.jsp.JspPage

    Choice 4 Only javax.servlet.jsp.tagext.Tag

    Choice 5 javax.servlet.jsp.tagext.TagSupport OR javax.servlet.jsp.tagext.BodyTagSupport

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

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

    1998 - 2002 Brainbench, Inc.All rights reserved.

  • Sample Code

    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?

    Choice 1 Anywhere within the document

    Choice 2 Only before any directives

    Choice 3 Only on the very first line of the document

    Choice 4 Only before any declarations

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

    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?

    Choice 1 JSP

    Choice 2 ASP

    Choice 3 HTML

    Choice 4 TLD

    Choice 5 PHP

    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?

    Choice 1 tldInfo.getTags()

    Choice 2 jspEngine.getTags()

    Choice 3 tagSupport.getTags()

    Choice 4 tagLibraryContext.getTags()

    Choice 5 tagLibraryInfo.getTags()

    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?

    Choice 1 JSP Page Changed

    Choice 2 Beans Valid

    Choice 3 Database Active

    Choice 4 JSP Engine Active

    Choice 5 JSP Page pre-compiled

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

    Choice 1 The security policy ensures that multiple security policy domains can exist within a single technology domain.

    Choice 2 The security policy may have groups to simplify setting of security policies.

    Choice 3 The security policy has a collection of users or principals.

    Choice 4 The security policy uses a well-defined authentication protocol(s) for authenticating users.

    Choice 5 The security policy contains an object that encapsulates single state information between two entities.

    Submit Java Server Pages (JSP 1.1), Question 26 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 CANNOT be defined inside a JSP page?

    Choice 1 A class method

    Choice 2 A _httpService method

    Choice 3 A _jspService method

    Choice 4 A class

    Choice 5 A static method

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

    Choice 1 Use a firewall or a proxy to discourage data from being sent back to the client browser.

    Choice 2 Mark sensitive Bean attributes as "Read-Only" in BeanInfo PropertyDescriptors.

    Choice 3 Do not place the Bean in the root or virtual root directory.

    Choice 4 Use a shadow Bean, also known as a proxy Bean, to set non-sensitive Bean properties.

    Choice 5 Avoid revealing the name of sensitive properties by not using Bean aliases.

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

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

    1998 - 2002 Brainbench, Inc.All rights reserved.

  • Sample Code

    How many instances of the "Ww.class" are created in the JSP engine after the JSP containing the above code is accessed five times?

    Choice 1 0

    Choice 2 1

    Choice 3 2

    Choice 4 4

    Choice 5 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 statement?

    Choice 1 http://www.xyz.com/code/tt.jsp

    Choice 2 http://www.xyz.com/jsp

    Choice 3 /f1/temp1.jsp

    Choice 4 ftp://ftp.xyz.com/dir1/temp1.jsp

    Choice 5 https://www.xyz.com

    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

    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 pageContext.getJspProperty()

    Choice 3 pageContext.getInfo()

    Choice 4 page.getServletInfo()

    Choice 5 page.getPageInfo()

    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

    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.

    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?

    Choice 1 Only to store meta information about the Tag

    Choice 2 To add extra validation to the custom tag and to declare new scripting variables introduced by the Tag

    Choice 3 To store meta information about the Tag and to add extra validation to the custom tag

    Choice 4 Only to add extra validation to the custom tag

    Choice 5 Only to declare new scripting variables introduced by the Tag

    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?

    Choice 1 Implement getVariableInfo() on a TagExtraInfo class

    Choice 2 Add .. to the tag's Tag Library Descriptor (TLD) entry

    Choice 3 Implement a new TagAttributeInfo for each new Scripting Variable

    Choice 4 Implement getScriptingVariables on a TagInfo class

    Choice 5 Implement getScriptingVariables to the tag's class implementation

    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

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

    Choice 2 response.encodeURL()

    Choice 3 response.getCharacterEncoding()

    Choice 4 response.getOutputStream()

    Choice 5 response.addCookie()

    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?

    Choice 1 page.getContext()

    Choice 2 request.getServletContext()

    Choice 3 application

    Choice 4 config.getContext()

    Choice 5 context

    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?

    Choice 1 Ability to distribute processing

    Choice 2 Dynamic modification of the browser

    Choice 3 Macros

    Choice 4 Compile time checking

    Choice 5 New actions

    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?

    Choice 1

    Choice 2

    Choice 3

    Choice 4

    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

    When the declaration above is made in a JSP, in which method is the String object "t1" declared?

    Choice 1 Not in any method

    Choice 2 init method

    Choice 3 doGet method

    Choice 4 doPost method

    Choice 5 service method

    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?

    Choice 1 doBeforeTag

    Choice 2 Clear Buffer

    Choice 3 Read in Tag's Body

    Choice 4 Set Attributes

    Choice 5 Initialize Tag's Body

    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