Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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 ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Another Problem

Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 !
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic