Web Application Creation Tutorial

From PresenceWiki
Jump to: navigation, search
Tutorial Pages > Web Application Creation Tutorial


This document describes the processes needed to create and deploy a Presence Web Application.

Prerequisites

For this tutorial you will need to install and run a Servlet Engine such as Tomcat:

A full list of J2EE compliant Servlet Engines is available over at servlets.com. Each vendor may provide its own mechanism for deploying web application archives (WARs) so you should check the documentation for whichever Servlet engine you're using.

Part 1: Task Creation

For this example we will create a simple application that asks the user's name and then returns some information about the name. For this we will need two Tasks which:

  • Display a page requesting the user's name
  • Display a page showing information about the user's name

In a real world example both of these pages could be generated by a single Task, but we want to demonstrate multiple Tasks being used by a Web Application. The Tasks can be downloaded from here. Go ahead and extract the zip file then import the XML file into Presence.

Once imported, you can test the functionality by running the Presence HTTP Server then directing your web browser to the following URL:

http://[server name]:[http port]/task/requestName

Try it out. You won't be very impressed, but if you can submit the form and receive a suitable response then it is working which is the main thing.

Part 2: Web Application Creation

The next step is to create our WAR file which we will later deploy to our Servlet Engine.

In the Presence Administration Client select Tools > Create Web Application from the top menu. You will then be presented with the first screen of the Web Application Wizard. Complete this information using the example below as a guide:

Webapp 1.png

Click "Next >" to specify which Tasks you want to include in your Web Application. Drag the Category containing our two Tasks into the right-hand Table. Aliases will be autogenerated, but you can change them by right-clicking on a Task and selecting "Change Alias" from the pop-up menu:

Webapp 2.png

Click "Next >" to view the Resources screen. This project doesn't require any external resources, but if you need to include things like images and style-sheets then this is the place to do it. Click Next again to proceed to the Libraries screen. Again, we shouldn't need any external libraries for this project so you can skip this screen as well and proceed to the "Create WAR File" screen:

Webapp 3.png

We will call our WAR file "nameanalysis.war" and save it to the root of the C: drive. If you want to call it something else, or save it elsewhere, feel free to do so - just remember where you put it as you'll need it later.

Part 3: Deployment

The final part of the exercise is to deploy our Web App to our Servlet Engine. If you are using Tomcat this will be very straightforward: Just drop the newly created WAR file into the "webapps" directory within "tomcat". Assuming that Tomcat is running it will automatically extract the archive file and the web application should be immediately available. As you can see in the image below, a new directory matching the name of the WAR file has been created, which contains the extracted contents of the WAR file:

Deploy tomcat.png

Once this is done, you can browse to your application using the following URL:

http://[server name]:[tomcat port]/nameanalysis/task/requestName

If all has gone well you should now see the output from the Name Request Task and the form should work as it did when running through the Presence HTTP Server. The difference is that Presence is no longer involved in running the Tasks - you can shut down the Presence Server and database server and the Tasks will still run quite happily.


Tutorial Pages > Web Application Creation Tutorial