# HG changeset patch # User paulb # Date 1191623425 0 # Node ID bd9eabd4042ca37e9ef0f625671e7249e5890102 # Parent 3c8b7f544a0db5a3f94844a795ca0b4b84bf26b8 [project @ 2007-10-05 22:30:22 by paulb] Added a test of JSP working with a WebStack application. diff -r 3c8b7f544a0d -r bd9eabd4042c examples/JavaServlet/JSPTest/Common/JSPTest/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/JavaServlet/JSPTest/Common/JSPTest/__init__.py Fri Oct 05 22:30:25 2007 +0000 @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +"A simple application for test purposes." + +import WebStack.Generic + +class JSPTestResource: + + "A simple resource." + + def respond(self, trans): + + # Store some information in attributes. + + print "Attributes..." + attr = trans.get_attributes() + attr["hello"] = "world" + rd = trans.get_servlet().getServletConfig().getServletContext().getRequestDispatcher("/test.jsp") + print "Forward..." + rd.forward(trans.request, trans.response) + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r 3c8b7f544a0d -r bd9eabd4042c examples/JavaServlet/JSPTest/JSPTestApp.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/JavaServlet/JSPTest/JSPTestApp.py Fri Oct 05 22:30:25 2007 +0000 @@ -0,0 +1,9 @@ +#!/usr/bin/env python + +from WebStack.Adapters.JavaServlet import deploy +from JSPTest import JSPTestResource + +JSPTestApp = deploy(JSPTestResource(), handle_errors=0) +print "Deployed." + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r 3c8b7f544a0d -r bd9eabd4042c examples/JavaServlet/JSPTest/test.jsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/JavaServlet/JSPTest/test.jsp Fri Oct 05 22:30:25 2007 +0000 @@ -0,0 +1,9 @@ + + + Test of JSP + + +

Hello <%= request.getAttribute("hello") %>! (attribute "hello")

+

Goodbye <%= request.getParameter("hello") %>! (parameter "hello")

+ +