FileDocCategorySizeDatePackage
ShowSource.javaAPI DocGlassfish v2 API3437Fri May 04 22:34:22 BST 2007examples

ShowSource

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

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);

        InputStreamReader reader = new InputStreamReader(in);
	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;