Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubts in MockExam HFSJ  RSS feed

Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)


Couldnt undertsand why E is corerct.

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;

Answer B
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!