• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doStartTag()

 
Kanishka Ajwani
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider the following code for the doStartTag() method of a Tag:


Which of the following lines of code can be placed at LINE 1 above, so that the request can be forwarded to page2.jsp?




Select 1 correct option.
a RequestDispatcher rd = request.getRequestDispatcher("page2.jsp"); rd.forward(request, response);
b pageContext.forward("page2.jsp");
c RequestDispatcher rd = pageContext.getRequestDispatcher("page2.jsp"); rd.forward(request, response);
d request.forward("page2.jsp");
e None of these.


The author says the correct answer is "b". However I have the following doubts in mind:
1) The method doStartTag() signature is public int doStartTag(). but here the return type is declared void.

2)When the method is declared to return void, how can it return EVAL_BODY_INCLUDE from the if construct?

3)The author seems to be assuming that pageContext is available as an implicit object to this class. According to me, since we have not been told which class is being extended by this tag handler, its incorrect to say that "b" is correct.

Therefore, I think the correct answer should be "e".

Am I thinking right? Please correct me if I am wrong.

Thanks.
 
Ankit Garg
Sheriff
Posts: 9580
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which book are you talking about?? Maybe if you check the errata you'll find this error listed there...
 
Kanishka Ajwani
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ankit,

I found this question on this link:
http://www.enthuware.com/forum/viewtopic.php?f=31&t=13

Check Q. 10.

Thanks,
Kanishka
 
Ankit Garg
Sheriff
Posts: 9580
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with both your concerns. The return type is wrong and the question should state that the class extends TagSupport class for we to assume pageContext object is available...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic