Using Jaxer with Apache Tomcat

Jaxer support can be added to Apache Tomcat via the inclusion of two WAR files.

Configuring Tomcat and Jaxer
Copy the jaxer.war and jaxer-server.war files into your webapps directory in your Tomcat home directory.

Configuring the two web.xml files in these war files allows you to connect the Jaxer servlet and Jaxer filter with your running Jaxer server. The two most common parameters that may need to be changed will be the hostname and port of your currently running Jaxer server. The included web.xml files use localhost and 5370 by default.

Jaxer Filter Parameters configured via the init-param element in the web.xml:

  • JAXER_PORT - the connector port of the Jaxer server
  • JAXER_HOSTNAME - the hostname of the Jaxer server
  • IGNORE_PATHS - a list of path segments that when encountered should bypass being processed by Jaxer
  • REQUEST_PATH - the request path of the Jaxer callback, only needed when using the JaxerFilter as a callback filter

Jaxer Servlet Parameters configured via the init-param element in the web.xml:

  • REQUEST_PATH - the request path of the Jaxer callback that should be handled exclusively by the Jaxer servlet

Necessary WAR files:

  • jaxer-server.war
    • This war file is used to handle Jaxer callbacks made by your page
    • WEB-INF
      • web.xml
        • This file configures a filter and server for the /callback URL pattern.
      • lib
        • interfaces.jar (Interfaces implemented by the filter and servlet to allow runtime configuration)
        • jaxer_servlet.jar (Servlet and filter classes as well as classes to communicate directly with Jaxer)
  • jaxer.war
    • This war file contains a sample Jaxer application that uses JSP and HTML
    • WEB-INF
      • web.xml
        • This file configures a filter that communicates directly with Jaxer for all requests ending in .html, .html, .HTML, .HTM, .jsp, .jspx
      • lib
        • interfaces.jar (Interfaces implemented by the filter and servlet to allow runtime configuration)
        • jaxer_servlet.jar (Servlet and filter classes as well as classes to communicate directly with Jaxer)

Include Jaxer-Tomcat sample
The jaxer-server.war is required to run any Tomcat applications through Jaxer. It provides the handlers needed for any Jaxer callbacks used by your pages. The jaxer.war file contains two samples of integration between Jaxer and Tomcat. The console.html file contains a simple console written in HTML that uses Javascript and the Jaxer Framwork to run entered content as a JSP page and view the results. The index.html shows a sample is mixing client-side JavaScript, server-side JavaScript, and JSP to create a simple application that allows users to translate date and number formats to their current locale.

Once you install the WAR files open a browser to http://<TOMCAT_ADDRESS>/jaxer/ or http://<TOMCAT_ADDRESS>/jaxer/console.html to view the sample applications.

How do I use Tomcat in Aptana Studio?

  1. Open the Servers view via Window->Show View->Other...->Aptana Standard Views->Servers
  2. Select the Add Server dropdown menu on the Servers view toolbar and select Connect to Generic Web Server
  3. Enter a server name such as myTomcat
  4. Enter the hostname (Tomcat default is localhost)
  5. Enter the port (Tomcat default is 8080)
  6. You can optionally add a heartbeat URL for monitoring your server status from Aptana Studio (a sample would be http://localhost:8080/jaxer)
  7. Select OK
  8. Select File->New->Project...
  9. Select Default Web Project under the Aptana Projects category and select Next
  10. Enter jaxer as the project name
  11. Deselect the Use default location checkbox
  12. Enter the location <TOMCAT_HOME>/webapps/jaxer and select Next
  13. Select Default custom preview settings for this project on the HTML Preview Settings wizard page
  14. Select the Use Server radio button
  15. Select your Tomcat server from the Server drop-down
  16. Select the box for Append project name
  17. Select Finish

Files inside the project can now be previewed against your Tomcat server inside the HTML editor.

Servlet Souce code:
The source code for the Jaxer filter and servlet code can be found at the following SVN urls:
The com.aptana.ide.framework.jaxer.server.servlet package in the Jaxer plugin
The com.aptana.ide.server.jetty.interfaces package in the Jetty plugin

AttachmentSize
jaxer-server.war79.18 KB
jaxer.war93.23 KB