| Author |
Another Problem
|
rashmi wadhera
Ranch Hand
Joined: Apr 06, 2004
Posts: 44
|
|
What wud be the solution to this problem. anyone share the mothod of solving this. Select any one The contents of tag handler class MyPage. are package tags; import javax.servlet.http.*; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; import java.io.*; public class MyPage extends BodyTagSupport { int k=10; public int doStartTag() throws JspException { return EVAL_BODY_INCLUDE; } public int doAfterBody() throws JspException { if(k<13) { k++; return EVAL_BODY_TAG; } return SKIP_BODY; } public int doEndTag() throws JspException { return EVAL_PAGE; } } the contents of tag library descriptor mypage.tld are : <tag> <name>mypage</name> <tagclass>tags.MyPage</tagclass> <bodycontent>JSP</bodycontent> </tag> </taglib> the contents of jsp file are <HTML> <HEAD> <%@ taglib uri="page.tld" prefix="he"%> </head> <he:mypage> <%="Hello "%> </he:mypage> </html> On executing jsp file guess Hello would be printed how many times A Not even Once B Once C Twice D Four
|
SCJP1.4, SCWCD1.4 (preparing)
|
 |
Frederic Filiatrault
Ranch Hand
Joined: Jul 12, 2004
Posts: 69
|
|
Hi again ! I know what was your problem. You think 3 and it is not in the solution. What a luck for you ! That means there's a trap. Answer : 4 times. It is doAFTERbody, not doSTARTbody. Condition is evaluated after printed. So, 10, 11, 12 are good but even 13 since AFTER it will not return to evaluate the body again. Hope this help !
|
F.<br />SCJP, SCJD, SCWCD, SCBCD<br /> <br />Failure is not an option... It comes with the software bundle.
|
 |
 |
|
|
subject: Another Problem
|
|
|