forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgard...@apache.org
Subject svn commit: r476663 - /forrest/trunk/whiteboard/forrest2/src/docs/readme.html
Date Sat, 18 Nov 2006 23:52:28 GMT
Author: rgardler
Date: Sat Nov 18 15:52:27 2006
New Revision: 476663

URL: http://svn.apache.org/viewvc?view=rev&rev=476663
Log:
Add an example of a doGet method for a servlet to process Forrest requests.

Modified:
    forrest/trunk/whiteboard/forrest2/src/docs/readme.html

Modified: forrest/trunk/whiteboard/forrest2/src/docs/readme.html
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/src/docs/readme.html?view=diff&rev=476663&r1=476662&r2=476663
==============================================================================
--- forrest/trunk/whiteboard/forrest2/src/docs/readme.html (original)
+++ forrest/trunk/whiteboard/forrest2/src/docs/readme.html Sat Nov 18 15:52:27 2006
@@ -301,7 +301,32 @@
 <p>As another example, here is the doGet method of a servlet that will route requests
to
 Forrest and stream the results back to the requesting client.</p>
 
-<div class="todo"> show the webapp servlet class.</div>
+<div class="code">
+<pre>
+	public void doGet(HttpServletRequest request, HttpServletResponse response)
+			throws ServletException, IOException {
+
+		response.setContentType("text/html");
+		PrintWriter out = response.getWriter();
+		URI requestURI;
+		try {
+			requestURI = new URI(request.getContextPath());
+			AbstractOutputDocument doc;
+			try {
+				doc = controller.getOutputDocument(requestURI);
+			} catch (ProcessingException e) {
+				throw new ServletException(e);
+			}
+			out.println(doc.getContentAsString());
+		} catch (URISyntaxException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		out.flush();
+		out.close();
+	}
+</pre>
+</div>
 
 <h2>Running Forrest 2.0 as a Webapp</h2>
 



Mime
View raw message