File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubts in MockExam HFSJ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubts in MockExam HFSJ" Watch "Doubts in MockExam HFSJ" New topic
Author

Doubts in MockExam HFSJ

sravanthi pulukuri
Ranch Hand

Joined: Mar 15, 2007
Posts: 125
Which are valid method calls on a PageContext object?
(Choose all that apply.)
A. getAttributeNames()
B. getAttribute(“key”)
C. findAttribute(“key”)
D. getSessionAttribute()
E. getAttributesScope(“key”)
F. findAttribute(“key”, PageContext.SESSION_SCOPE)
G. getAttribute(“key”, PageContext.SESSION_SCOPE)

b,c,e,g

Couldnt undertsand why E is corerct.

2:
Given:
10. public class BufTag extends BodyTagSupport {
11. public int doStartTag() throws JspException {
12. // insert code here
13. }
14. }
Assume that the tag has been properly configured to allow body content.
Which, if inserted at line 12, would cause the JSP code
<mytags:mytag>BodyContent</mytags:mytag> to output BodyContent?
A. return SKIP_BODY;
B. return EVAL_BODY_INCLUDE;
C. return EVAL_BODY_BUFFERED;
D. return BODY_CONTENT;

Answer B
Sourin K. Sen
Ranch Hand

Joined: May 02, 2006
Posts: 86

Hi sravanthi,

Here are the answers to your questions :

1. PageContext is a sub-class of JspContext and hence inherits its methods. The methods inherited from JspContext are :
findAttribute, getAttribute, getAttribute, getAttributeNamesInScope, getAttributesScope, getExpressionEvaluator, getOut, getVariableResolver, popBody, pushBody, removeAttribute, removeAttribute, setAttribute, setAttribute

Hence option E is right

2. If you dont need to do any kind of manipulations on the body between the tag, then you dont need to buffer it. You can directly send the control to doAfterBody() method if you need to only print the body. Remeber though, that when you extend the BodyTagSupport class, EVAL_BODY_BUFFERED becomes the default return type of doStartTag() method, but still, its not the only one which can be returned from the method. You still have SKIP_BODY and EVAL_BODY_INCLUDE at your disposal. You will use EVAL_BODY_BUFFERED if and only if you need to do some kind of calculations or manipulations or something particular you want to do the body.


Regards,<br />Sourin.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubts in MockExam HFSJ
 
Similar Threads
HFSJ : page:553 Q:9
Question from Head First book chapter 10
getAttributeScope(String name)
Doubts in given answers..
Custom Tags