1 16 17 package org.apache.taglibs.standard.examples.util; 18 19 import java.io.*; 20 import javax.servlet.jsp.JspException ; 21 22 28 public class IOBean { 29 StringWriter stringWriter = null; 30 String content = null; 31 32 public Reader getReader() throws JspException { 33 if (content == null) { 35 if (stringWriter == null) { 36 throw new JspException ( 37 "content must first be added to the bean via the writer"); 38 } 39 content = stringWriter.toString(); 40 } 41 return new StringReader(content); 42 } 43 44 public Writer getWriter() { 45 content = null; 47 stringWriter = new StringWriter(); 48 return stringWriter; 49 } 50 51 public void release() { 52 stringWriter = null; 53 content = null; 54 } 55 56 private void p(String s) { 57 System.out.println("[IOBean] " + s); 58 } 59 } 60 | Popular Tags |