You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ak...@hyperreal.org on 1999/11/19 02:30:25 UTC
cvs commit: jakarta-tomcat/src/examples/jsp/num numguess.html
akv 99/11/18 17:30:23
Modified: src/examples/WEB-INF/jsp example-taglib.tld
src/examples/jsp/num numguess.html
Added: src/examples/WEB-INF/classes/jsp/tags/examples
ShowSource.java
src/examples/jsp source.jsp
Log:
A custom tag to display JSP sources. See numguess.html for how it is intended
to be used.
Will clean up the *.txt files for the JSP sources later.
Revision Changes Path
1.1 jakarta-tomcat/src/examples/WEB-INF/classes/jsp/tags/examples/ShowSource.java
Index: ShowSource.java
===================================================================
package 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 {
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();
}
}
1.4 +11 -0 jakarta-tomcat/src/examples/WEB-INF/jsp/example-taglib.tld
Index: example-taglib.tld
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/examples/WEB-INF/jsp/example-taglib.tld,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- example-taglib.tld 1999/11/08 03:12:58 1.3
+++ example-taglib.tld 1999/11/19 01:30:13 1.4
@@ -18,6 +18,17 @@
A simple tab library for the examples
</info>
+ <tag>
+ <name>ShowSource</name>
+ <tagclass>examples.ShowSource</tagclass>
+ <info> Display JSP sources </info>
+ <attribute>
+ <name>jspFile</name>
+ <required>true</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ </tag>
+
<!-- A simple Tag -->
<!-- foo tag -->
<tag>
1.1 jakarta-tomcat/src/examples/jsp/source.jsp
Index: source.jsp
===================================================================
<%@ taglib uri="http://java.apache.org/tomcat/examples-taglib" prefix="eg" %>
<eg:ShowSource jspFile="<%= request.getQueryString() %>"/>
1.3 +1 -1 jakarta-tomcat/src/examples/jsp/num/numguess.html
Index: numguess.html
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/examples/jsp/num/numguess.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- numguess.html 1999/10/20 23:49:47 1.2
+++ numguess.html 1999/11/19 01:30:20 1.3
@@ -15,7 +15,7 @@
<body bgcolor="#FFFFFF">
<p><font color="#0000FF"><a href="numguess.jsp"><img src="../../images/execute.gif" align="right" border="0"></a><a href="../index.html"><img src="../../images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
-<h3><a href="numguess.txt">Source Code for Numguess Example<font color="#0000FF"></a>
+<h3><a href="/examples/jsp/source.jsp?/jsp/num/numguess.jsp">Source Code for Numguess Example<font color="#0000FF"></a>
</font> </h3>
</body>