showsource.java

来自「一个java写的加密算法」· Java 代码 · 共 63 行

JAVA
63
字号
/* * Copyright 2004-2005 Sun Microsystems, Inc.  All rights reserved. * Use is subject to license terms. */package samples.webapps.simple.beans.examples;import javax.servlet.*;import javax.servlet.jsp.*;import javax.servlet.jsp.tagext.*;import java.io.*;/** * Display the sources of the JSP file. */public class ShowSource    extends TagSupport{    String jspFile;        public void setJspFile(String jspFile) {        this.jspFile = jspFile;    }    public int doEndTag() throws JspException {	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("&lt;");                else                    out.print((char) ch);            out.println("</pre>");            out.println("</body>");        } catch (IOException ex) {            throw new JspTagException("IOException: "+ex.toString());        }        return super.doEndTag();    }}                

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?