Hiding /cocoon from the URL (cookbook)

  • TARGET-AUDIENCE: *beginner* advanced expert
  • COCOON-RELEASES: 2.0.3, 2.0.4
  • DOCUMENT-STATUS: *draft* reviewed released

What you will get from this page

I will show you, how you can get the /cocoon out of the URL. If you want to know how you can get your company server to use cocoon without exploiting the tomcat port (8080) you also need to read the document BeginnerDefaultPort.

This approach works for the apache/tomcat working horse. For other application servers this document is not applicable.

Your basic skills

  • You have some basic idea of how cocoon, tomcat and apache interact
  • You know how to edit the configuration files.

Technical prerequisites

  • You have installed at least an apache-1.3.19 server
  • You have installed tomcat 4.0 or newer
  • You have installed a recent version of cocoon (see above)

Links to other information sources

Configuring tomcat

In short terms you setup a tomcat default context, where cocoon happens to be the default webapplication to be triggered. Here we go:

  • Go to the tomcat home directory ($tomcat_home)
  • Now enter the subfolder "conf" and edit the file server.xml
  • Look for the following code snippet:
    <!-- Tomcat Root Context -->
      <!--
         <Context path="" docBase="ROOT" debug="0"/>
      -->
    
    Note: in some versions of tomcat the Root Context is not disabled as shown above. If in your tomcat version it is enabled, disable it now (use the XML-comment brakets as shown above).
  • Create a new <Context> right below the Tomcat Root Context definition and save your modifications:
    <Context path="" 
             docBase="/path/to/cocoon/webapp"
             debug="0"/>
    

Some notes on the Context attributes:

  1. By defining a <Context> with the path="" we have created a default Context. Now tomcat directs every request to Cocoon, which can not explicitly be associated to another webapplication.
  2. By setting docBase to an absolute path we have directed tomcat to mount the webapplication from that path. We could also have used a relative path, which would be resolved relative to $cocoon_root/webapps but beware ...:

Important NOTE: If you deploy cocoon into the default webapp directory AND setup a Context within server.xml for the same webapplication, it will be mounted twice: once for the default context and once via automatic mount from the webapps folder. This is true even if docBase points to $tomcat_root/webapps/cocoon!!! As this is probably NOT what you want to do, you must deploy cocoon elsewhere to avoid the automounting.

What did we achieve?

I.e. the following URL:

http:/mycompany:8080/myapp

now points to the same place as the formerly used URL:

http://mycompany:8080/cocoon/myapp

And now eliminate the port...

As stated at the beginning of this document, you may want to also eliminate the port from your URL. If you want to this, please read the accompanion document BeginnerDefaultPort.


page metadata

  • AUTHOR:Hussayn Dabbous
  • No labels