pageContext.getAttribute(“foo”);
getPageContext().getAttribute(“foo”);
pageContext.getApplicationScope(“foo”);
pageContext.getAttribute(“foo”,pageContext.APPLICATION_SCOPE).getAttribute(“foo”);
getPageContext().getScope(pageContext.APPLICATION_SCOPE).getAttribute(“foo”);
第1题:
A custom JSP tag must be able to support an arbitrary number of attributes whose names are unknown when the tag class is designed. Which two are true? ()
第2题:
Given: 6.
第3题:
Assume the tag handler for a st:simple tag extends Simple Tag Support. In what way can scriptlet code beused in the body of st:simple?()
第4题:
A custom tag is defined to take three attributes. Which two correctly invoke the tag within a JSP page?()
第5题:
Given the JSP code: <% request.setAttribute("foo", "bar"); %>and the Classic tag handler code: 5. public int doStartTag() throws JspException { 6. // insert code here 7. // return int 8. } Assume there are no other "foo" attributes in the web application. Which invocation on the pageContextobject,inserted at line 6,assigns "bar" to the variable x?()
第6题:
ItemSimpleTag can find the enclosing instance of ShoppingListTag by calling getParent() and castingthe result to ShoppingListTag.
ShoppingListTag can find the child instances of ItemSimpleTag by calling super.getChildren() andcasting each to an ItemSimpleTag.
It is impossible for ItemSimpleTag and ShoppingListTag to find each other in a tag hierarchy becauseone is a Simple tag and the other is a Classic tag.
ShoppingListTag can find the child instances of ItemSimpleTag by calling getChildren() on thePageContext and casting each to an ItemSimpleTag.
ItemSimpleTag can find the enclosing instance of ShoppingListTag by calling findAncestorWithClass()on the PageContext and casting the result to ShoppingListTag.
第7题:
Set the body content type to JSP in the TLD
Scriptlet code is NOT legal in the body of st:simple
Add scripting-enabled= “true” to the start tag for the st:simple element
Add a pass-through Classic tag with a body content type of JSP to the body of st:simple, and place the scriptlet code in the body of that tag.
第8题:
int foo() { /* more code here */ }
void foo() { /* more code here */ }
public void foo() { /* more code here */ }
private void foo() { /* more code here */ }
protected void foo() { /* more code here */ }
第9题:
It is impossible to determine the deepest nesting depth because it is impossible for tag handlers that extend SimpleTagSupport to communicate with their parent and child tags
Create a private non-static attribute in the tag handler class called count of type int initialized to oIncrement count in the doTag method. If the tag has a body, invoke the fragment for that body. Otherwise, output the value of count
Start a counter at 1. Call getChildTags(). If it returns null, output the value of the counter. Otherwise, increment counter and continue from where getChildTags() is called. Skip processing of the body.
If the tag has a body, invoke the fragment for that body. Otherwise, start a counter at 1. Call getParent(). If it returns null, output the value of the counter. Otherwise, increment the counter and continue from where getParent() is called.
第10题:
<prefix:myTag a=foo b=bar c=baz />
<prefix:myTag attributes={foo,bar,baz} />
<prefix:myTag jsp:attribute a=foo b=bar c=baz />
<prefix:myTag><jsp:attribute name=a>foo</jsp:attribute><jsp:attribute name=b>bar</jsp:attribute><jsp:attribute name=c>baz</jsp:attribute>. </prefix:myTag>
第11题:
Set the body content type to JSP in the TLD
Scriptlet code is NOT legal in the body of st:simple.
Add scripting-enabled=true to the start tag for the st:simple element
Add a pass-through Classic tag with a body content type of JSP to the body of st:simple, and place the scriptlet code in the body of that tag
第12题:
Object o = pageContext.getAttribute(foo);
Object o = pageContext.findAttribute(foo);
Object o = pageContext.getAttribute(foo,PageContext.SESSION_SCOPE);
HttpSession s = pageContext.getSession();Object o = s.getAttribute(foo);
第13题:
class One { void foo() {} } class Two extends One { //insert method here } Which three methods, inserted individually at line 14, will correctly complete class Two?()
第14题:
Assume a tag handler extends TagSupport. Which is used within the tag handler to get an attribute “foo” that is in the application scope?()
第15题:
class One { public One foo() { return this; } } class Two extends One { public One foo() { return this; } } class Three extends Two { // insert method here } Which two methods, inserted individually, correctly complete the Three class?()
第16题:
Assume the tag handler for a st:simpletag extends SimpleTagSupport. In what way can scriptlet code be used in the body of st:simple?()
第17题:
The sl:shoppingList and sl:item tags output a shopping list to the response and are used as follows:
第18题:
pageContext.getAttribute(“foo”);
getPageContext().getAttribute(“foo”);
pageContext.getApplicationScope(“foo”);
pageContext.getAttribute(“foo”,pageContext.APPLICATION_SCOPE).getAttribute(“foo”);
getPageContext().getScope(pageContext.APPLICATION_SCOPE).getAttribute(“foo”);
第19题:
<jsp:import file=’foo.jsp’ />
<jsp:import page=’foo.jsp’ />
<jsp:include page=’foo.jsp’ />
<jsp:include file=’foo.jsp’ />
第20题:
public void foo() { }
public int foo() { return 3; }
public Two foo() { return this; }
public One foo() { return this; }
public Object foo() { return this; }
第21题:
String value = getServletConfig( ).getParameter(“foo”);
String value = getServletContext( ).getAttribute(“foo”);
Object value = getServletContext( ).getInitParameter(“foo”);
String value = getServletContext( ).getInitParameter(“foo”)
第22题:
The doStartTag method is called once.
The doAfterBody method is NOT called.
The EVAL_PAGE constant is a valid return value for the doEndTag method.
The SKIP_PAGE constant is a valid return value for the doStartTag method.
The EVAL_BODY_BUFFERED constant is a valid return value for the doStartTag method.
第23题:
String x = (String) pageContext.getAttribute(foo)
String x = (String) pageContext.getRequestScope(foo)
It is NOT possible to access the pageContext object from within doStartTag
String x = (String) pageContext.getRequest().getAttribute(foo)
String x = (String) pageContext.getAttribute(foo, PageContext.ANY_SCOPE)
第24题:
The doStartTag method is called once.
The doAfterBody method is NOT called.
The EVAL_PAGE constant is a valid return value for the doEndTag method.
The SKIP_PAGE constant is a valid return value for the doStartTag method.
The EVAL_BODY_BUFFERED constant is a valid return value for the doStartTag method.