FileDocCategorySizeDatePackage
ShowSource.javaAPI DocApache Tomcat 6.0.142221Fri Jul 20 04:20:34 BST 2007examples

ShowSource

public class ShowSource extends TagSupport
Display the sources of the JSP file.

(Omit source code)

Fields Summary
String
jspFile
Constructors Summary
Methods Summary
public intdoEndTag()

	if ((jspFile.indexOf( ".." ) >= 0) ||
            (jspFile.toUpperCase().indexOf("/WEB-INF/") != 0) ||
            (jspFile.toUpperCase().indexOf("/META-INF/") != 0))
	    throw new JspTagException("Invalid JSP file " + jspFile);

        InputStream in
            = pageContext.getServletContext().getResourceAsStream(jspFile);

        if (in == null)
            throw new JspTagException("Unable to find JSP file: "+jspFile);

        JspWriter out = pageContext.getOut();


        try {
            out.println("<body>");
            out.println("<pre>");
            for(int ch = in.read(); ch != -1; ch = in.read())
                if (ch == '<")
                    out.print("<");
                else
                    out.print((char) ch);
            out.println("</pre>");
            out.println("</body>");
        } catch (IOException ex) {
            throw new JspTagException("IOException: "+ex.toString());
        }
        return super.doEndTag();
    
public voidsetJspFile(java.lang.String jspFile)

        this.jspFile = jspFile;