NavigationUser login |
JSP and Servlets DemoHow to use the Hello, World JSP and Servlet Demos This demo consists of two parts. In the first part, we show how to use a JSP page; in the second part, we show how to use a servlet. Both are "hello, world" demos and don't otherwise do anything useful. Download and unzip the source files. Server Notes First, a quick overview of Voxeo's servers. Voxeo uses "Mbedthis AppWeb" (http://www.mbedthis.com) as its server for ordinary web pages and PHP-enabled pages, and this server runs on port 9990. (If you'd like to see this for yourself, create a PHP page containing the code <?phpThe other server, the one we'll be looking at, is based on Jetty (http://jetty.org). That server is used for JSP and servlets, and runs on port 9991. Its home directory is in Voxeo/webapps. The Jetty server is the "vappserver" process that starts up as part of Prophecy, and its log files are in Voxeo/Logs/vappserver. JSP Demo To use the JSP demo, place it in a *sub* directory of Voxeo/webapps, not the directory itself. Let's say you copy our distribution's jsp/helloworld.jsp to Voxeo/webapps/demo/helloworld.jsp. Restart the Jetty server ("prophecy restart vappserver"). If you machine's name is "foo," then point your browser at http://foo:9991/jsp/helloworld.jsp. You should get a "Hello, world" and "JSP is number 1" on your browser, looking like ordinary HTML. Servlet Demo In this demo, we will create a WAR file. By dropping the WAR file into Voxeo/webapps, Jetty will use the servlet to respond to your HTTP request. (Tech Note: it isn't clear to me at this time just when servlets are initialized by Jetty.) Configuration: Ant, build.xml, web.xml This demo uses the Ant tool to compile the Java and create the WAR file. Ant is available across a wide set of platforms and is part of the Apache project (http://apache.org). And uses "build.xml," which is at the top level of our demo hierarchy, to find the files to compile. The only real configuration parameter in build.xml is the location of the jar library file for the Java servlet classes. In build.xml, the classpath element contains an element called pathelement, and I've set it to"/pc/flute/etc.," which is the path to javax.servlet.jar on my system. Please set the pathelement element to the location of the appropriate jar file on your system; it's likely to be in C:/Program Files/Voxeo/Jetty/lib. Web.xml is the standard web configuration file that tells the server where your servlet resides and what HTTP request the servlet should respond to. Jetty is sensitive about web-app, and unless you include all the declarations in the sample web.xml file, you'll see a complaint about web.xml in Logs/vappserver/server.log and the servlet will not load. We've set the servlet to respond to "HelloWorld.do." Build: Step 1. Type "ant." This will create the WAR file in the top-level directory. Deploy: Step 1. Copy the WAR file to Program Fies/Voxeo/webapps. You might wish to check Logs/vappserver/server.log to see if HelloWorld loaded, and you can check the Log viewer to see if there were any Java errors. Test: Point your browser to your test machine. Since the name of the WAR file is HelloWorld.war, the servlet is treated as if though it's in a directory named HelloWorld. Since we configured the name of the servlet as HelloWorld.do, we will look at that page. On a machine named "foo," the URL to see the output of HelloWorld is http://foo:9991/HelloWorld/HelloWorld.do. You should see what looks like an ordinary web page with "Hello, World" and "Welcome to the Hello, world! test page."
|
P2006 How-To BookBasic InformationSearchRecent blog posts
New forum topicsActive forum topics |