aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes dostartTag return value doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "dostartTag return value doubt" Watch "dostartTag return value doubt" New topic
Author

dostartTag return value doubt

Parth Twari
Ranch Hand

Joined: Jan 20, 2010
Posts: 163
Niko's question

Q.68
Assume that everything is declared properly and the TLD specifies <body-content>scriptless</body-content>. What is the output of the JSP? (1 correct answer)

public class Classic extends TagSupport {
public int doStartTag() {
return SKIP_PAGE;
}
}

<%@ taglib uri="correct" prefix="yes" %>
<html>
<body>
(Before)
<yes:classic>My Body</yes:classic>
(After)
</body>
</html>

1. (Before)(After)
2. (Before)
3. (Before)My Body(After)
4. (Before)My Body

Answer: 3

I tested it and its working fine! yes the answer comes out as 3 only but why? What i have read as valid return types for doStartTag are SKIP_BODY and EVAL_BODY_INCLUDE but its working correctly here. Can anyone explain why?

Parth Tiwari
| Pursuing Bachelor of Engineering | OSUM Club Leader | SCJP 6 | SCWCD 5 |...
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1529
    
  22

Hi Parth,

These are really trick questions that you won't come across on the real exam, don't worry about them too much.

First of all: it compiles because SKIP_PAGE is defined as a public static final int, the compiler doesn't know whether that value applies in this method
Secondly: it runs because the generated Servlet checks only on whether the body should be skipped: see part of the generated code (on tomcat):

The JSP2.0 spec doesn't say anything about what should be done if there is a wrong return code thrown from one the tag-methods, so I find the outcome of this question questionable.

Regards,
Frits

Parth Twari
Ranch Hand

Joined: Jan 20, 2010
Posts: 163
whew..so this worked because it was like this on tomcat 5

ok thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dostartTag return value doubt
 
Similar Threads
Classic Tag Quesion
JSP Custom Tag Lib
Extending BodyTagSupport (HFS CH10 Q9)
Classic Tag Handler
Doubt Enthuware Mock Exam