1 16 package org.apache.taglibs.xsl; 17 18 19 import javax.servlet.*; 20 import javax.servlet.jsp.*; 21 import javax.servlet.jsp.tagext.*; 22 23 import java.io.*; 24 25 30 31 public class ShowSource 32 extends TagSupport 33 { 34 String jspFile; 35 36 public void setJspFile(String jspFile) { 37 this.jspFile = jspFile; 38 } 39 40 public int doEndTag() throws JspException { 41 InputStream in 42 = pageContext.getServletContext().getResourceAsStream(jspFile); 43 44 if (in == null) 45 throw new JspTagException("Unable to find JSP file: "+jspFile); 46 InputStreamReader reader = new InputStreamReader(in); 47 48 JspWriter out = pageContext.getOut(); 49 50 try { 51 out.println("<body>"); 52 out.println("<pre>"); 53 for(int ch = in.read(); ch != -1; ch = in.read()) 54 if (ch == '<') 55 out.print("<"); 56 else 57 out.print((char) ch); 58 out.println("</pre>"); 59 out.println("</body>"); 60 } catch (IOException ex) { 61 throw new JspTagException("IOException: "+ex.toString()); 62 } 63 return super.doEndTag(); 64 } 65 } 66 67 68 69 70 | Popular Tags |