From 0e5f96b17340d53e0f2f1eb0384ca82bb0333edb Mon Sep 17 00:00:00 2001 From: Stefan Suhren Date: Mon, 2 Nov 2015 10:33:41 +0100 Subject: Don't use JspWriter --- src/de/fhswf/in/inf/fit/aufgabe4/Repeat.java | 44 ++++++++++++++++------------ 1 file changed, 26 insertions(+), 18 deletions(-) (limited to 'src/de/fhswf/in/inf') diff --git a/src/de/fhswf/in/inf/fit/aufgabe4/Repeat.java b/src/de/fhswf/in/inf/fit/aufgabe4/Repeat.java index d644ff9..2702f79 100644 --- a/src/de/fhswf/in/inf/fit/aufgabe4/Repeat.java +++ b/src/de/fhswf/in/inf/fit/aufgabe4/Repeat.java @@ -3,8 +3,6 @@ */ package de.fhswf.in.inf.fit.aufgabe4; -import java.io.IOException; - import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.BodyTagSupport; @@ -48,28 +46,38 @@ public class Repeat extends BodyTagSupport } /* - * (non-Javadoc) + * Make sure that the input body will be printed. * - * @see javax.servlet.jsp.tagext.BodyTagSupport#doEndTag() + * @see javax.servlet.jsp.tagext.BodyTagSupport#doStartTag() */ @Override - public int doEndTag() throws JspException + public int doStartTag() throws JspException { - String bodyText = bodyContent.getString(); - - for (int i = 0; i < times; i++) + if (times <= 0) { - try - { - pageContext.getOut().print(bodyText); - } - catch (IOException e) - { - e.printStackTrace(); - } + return SKIP_BODY; + } + else + { + return EVAL_BODY_INCLUDE; } - - return EVAL_PAGE; } + /* + * Repeat the body a given time. + * + * @see javax.servlet.jsp.tagext.BodyTagSupport#doAfterBody() + */ + @Override + public int doAfterBody() throws JspException + { + if (--times > 0) + { + return EVAL_BODY_AGAIN; + } + else + { + return SKIP_BODY; + } + } } -- cgit v1.2.3-70-g09d2