File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Another Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Another Problem" Watch "Another Problem" New topic

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.*;


public class MyPage extends BodyTagSupport {

int k=10;

public int doStartTag() throws JspException {



public int doAfterBody() throws JspException {

if(k<13) {




return SKIP_BODY;


public int doEndTag() throws JspException {

return EVAL_PAGE;



the contents of tag library descriptor mypage.tld are :







the contents of jsp file are



<%@ taglib uri="page.tld" prefix="he"%>



<%="Hello "%>



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.
I agree. Here's the link:
subject: Another Problem
It's not a secret anymore!