Differences between revisions 3 and 4
Revision 3 as of 2004-02-29 09:53:55
Size: 2209
Editor: AaronFarr
Comment: switched to CVS links. need to delete other pages -farra
Revision 4 as of 2009-09-20 23:16:57
Size: 2215
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 6: Line 6:
  * [http://cvs.apache.org/viewcvs.cgi/avalon-sandbox/examples/fortress/servlet/src/java/org/apache/avalon/examples/fortress/FortressServletLauncher.java?rev=1.1&view=markup FortressServletLauncher] : a Servlet Context Listener which loads the ServiceManager into the Servlet Context
  * [http://cvs.apache.org/viewcvs.cgi/avalon-sandbox/examples/fortress/servlet/src/webapp/index.jsp?rev=1.1&view=markup index.jsp] : a JSP which retrieves a service from the Servlet Context
  * [http://cvs.apache.org/viewcvs.cgi/avalon-sandbox/examples/fortress/servlet/src/java/org/apache/avalon/examples/fortress/FortressServlet.java?rev=1.1&view=markup FortressServlet] : a standard servlet which retrieves the service from the Servelet Context
  * [[http://cvs.apache.org/viewcvs.cgi/avalon-sandbox/examples/fortress/servlet/src/java/org/apache/avalon/examples/fortress/FortressServletLauncher.java?rev=1.1&view=markup|FortressServletLauncher]] : a Servlet Context Listener which loads the ServiceManager into the Servlet Context
  * [[http://cvs.apache.org/viewcvs.cgi/avalon-sandbox/examples/fortress/servlet/src/webapp/index.jsp?rev=1.1&view=markup|index.jsp]] : a JSP which retrieves a service from the Servlet Context
  * [[http://cvs.apache.org/viewcvs.cgi/avalon-sandbox/examples/fortress/servlet/src/java/org/apache/avalon/examples/fortress/FortressServlet.java?rev=1.1&view=markup|FortressServlet]] : a standard servlet which retrieves the service from the Servelet Context

Fortress Servlet HOWTO

The Fortress Servlet HOWTO shows how to launch a Fortress container in a J2EE webapp. In this example, the Fortress ServiceManager is placed in the Servlet Context. Servlets, JSP's, Struts Actions, etc. can then get services from the ServiceManager. Notice, though, that this means there will be a single Fortress container per webapp not application server. If you want to run a a single Fortress instance for all webapps you will probably need to put together JNDI bindings for the services via something like AltRMI.

The example has three parts (click to see source code)

A couple of notes to consider:

  • The Fortress Servlet Launcher is generic in that you could add this class to any of your webapps including Struts applications
  • A "better" solution to the JSP and Servlet would be to create an Abstract servlet or JSP tag which contains the ServiceManager lookup logic. This way you could swap out lookup mechanism (switch Merlin for Fortress) and not have to change your client code.

See http://cvs.apache.org/viewcvs.cgi/avalon-sandbox/examples/fortress/servlet/ for latest source code

To run:

  • Download lastest avalon-examples source distribution
  • move to the fortress/servlet directory
  • run  maven war 

  • copy the fortress-servlet.war file into your servlet container (i.e. Tomcat)
  • See the webapp at: http://localhost:8080/fortress/ (Tomcat example)

[Back to HowTo]

FortressServletExample (last edited 2009-09-20 23:16:57 by localhost)