You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sc...@apache.org on 2005/07/15 00:39:59 UTC
svn commit: r219123 - in /myfaces: build/trunk/build.xml
examples/trunk/sandbox/src/java/org/apache/myfaces/examples/servlet/
examples/trunk/sandbox/src/java/org/apache/myfaces/examples/servlet/SourceCodeServlet.java
Author: schof
Date: Thu Jul 14 15:39:52 2005
New Revision: 219123
URL: http://svn.apache.org/viewcvs?rev=219123&view=rev
Log:
Fixed source code servlet for sandbox webapp
Added:
myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/servlet/
myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/servlet/SourceCodeServlet.java
Modified:
myfaces/build/trunk/build.xml
Modified: myfaces/build/trunk/build.xml
URL: http://svn.apache.org/viewcvs/myfaces/build/trunk/build.xml?rev=219123&r1=219122&r2=219123&view=diff
==============================================================================
--- myfaces/build/trunk/build.xml (original)
+++ myfaces/build/trunk/build.xml Thu Jul 14 15:39:52 2005
@@ -611,7 +611,10 @@
<arg line="-doctitle 'Tag library for Apache MyFaces'"/>
<arg line="-xslt ${tlddoc.xslt.dir}"/>
<arg line="-d ${tlddoc.dir}"/>
+ <arg value="${resolved-tlds.dir}/*.tld"/>
+<!--
<fileset dir="${resolved-tlds.dir}" includes="*.tld"/>
+-->
</apply>
</target>
@@ -725,7 +728,7 @@
<property name="web.dir" value="${subproject.dir}/sandbox"/>
<property name="classes.dir" value="${temp.dir}/sandbox/classes"/>
<property name="src.dir" value="${subproject.dir}/sandbox/src/java"/>
- <property name="web.xml.file" value="${subproject.dir}/conf/basic-web.xml"/>
+ <property name="web.xml.file" value="${subproject.dir}/conf/web.xml"/>
</ant>
</target>
@@ -753,9 +756,6 @@
</classes>
<classes dir="${classes.dir}"/>
<lib dir="${examples.lib.dir}"/>
- <!--
- <lib dir="${dist.dir}" />
- -->
</war>
</target>
Added: myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/servlet/SourceCodeServlet.java
URL: http://svn.apache.org/viewcvs/myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/servlet/SourceCodeServlet.java?rev=219123&view=auto
==============================================================================
--- myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/servlet/SourceCodeServlet.java (added)
+++ myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/servlet/SourceCodeServlet.java Thu Jul 14 15:39:52 2005
@@ -0,0 +1,44 @@
+package org.apache.myfaces.examples.servlet;
+
+import javax.servlet.*;
+import javax.servlet.http.*;
+import java.io.*;
+
+public class SourceCodeServlet extends HttpServlet
+{
+ public void doGet(HttpServletRequest req, HttpServletResponse res)
+ throws IOException, ServletException
+ {
+ String webPage = req.getServletPath();
+
+ // remove the '*.source' suffix that maps to this servlet
+ int chopPoint = webPage.indexOf(".source");
+
+ webPage = webPage.substring(0, chopPoint - 1);
+ webPage += "p"; // replace jsf with jsp
+
+ // get the actual file location of the requested resource
+ String realPath = getServletConfig().getServletContext().getRealPath(webPage);
+
+ // output an HTML page
+ res.setContentType("text/plain");
+
+ // print some html
+ ServletOutputStream out = res.getOutputStream();
+
+ // print the file
+ InputStream in = null;
+ try
+ {
+ in = new BufferedInputStream(new FileInputStream(realPath));
+ int ch;
+ while ((ch = in.read()) !=-1)
+ {
+ out.print((char)ch);
+ }
+ }
+ finally {
+ if (in != null) in.close(); // very important
+ }
+ }
+}