Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Doubts in MockExam HFSJ

Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

The world's cheapest jedi mind trick: "Aw c'mon, why not read this tiny ad?"
We need your help - Coderanch server fundraiser
    Bookmark Topic Watch Topic
  • New Topic