diff options
| author | Stefan Suhren <suhren.stefan@fh-swf.de> | 2015-11-02 10:33:41 +0100 |
|---|---|---|
| committer | Stefan Suhren <suhren.stefan@fh-swf.de> | 2015-11-02 10:33:41 +0100 |
| commit | 0e5f96b17340d53e0f2f1eb0384ca82bb0333edb (patch) | |
| tree | 96abdb304f534f8f4bfc773e0952186c366edcad | |
| parent | 7c1c02eba005f8eea4d9088c89f887ef9b436b6e (diff) | |
| download | FIT-0e5f96b17340d53e0f2f1eb0384ca82bb0333edb.tar.gz FIT-0e5f96b17340d53e0f2f1eb0384ca82bb0333edb.zip | |
Don't use JspWriter
| -rw-r--r-- | src/de/fhswf/in/inf/fit/aufgabe4/Repeat.java | 44 |
1 files changed, 26 insertions, 18 deletions
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; + } + } } |
