tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From William Claxton <willi...@openasia.net>
Subject directory structure and porting issues
Date Sat, 10 Apr 2004 10:52:20 GMT
Folks, hi -

I keep stumbling into porting issues when moving older servlet applications 
from Jrun or Servlet Exec to Tomcat.  A couple issues related to directory 
structure always seem to arise.

One issue is that an application expecting all servlets to be loaded from a 
single classpath may not have the 'context' prefix.  For example, an 
application 'app1' that posts to '/servlet/Controller' may not work unless 
'app1' is defined as Tomcat's default context.  It would work if you change 
the code so that it posts to 'app1/servlet/Controller'.  But that's a 
global change that hardcodes the context name.

Incidentally, I observed the same issue when changing the 'appbase' in 
Tomcat's server.xml - the Tomcat home page is no longer accessible.  Even 
if you create a new 'tomcat' context, the admin, manager and servlet 
examples linked from Tomcat's homepage don't work.  A solution I found 
works in Tomcat 5 is to create new contexts for each, such as:

<Context path="tomcat/servlets-examples"
   docBase="c:\apps\java\tomcat\webapps\servlets-examples" debug="0" />

As I recall, this didn't work in Tomcat 4.

Another issue is that 'context' seems to function as both a 'script-alias' 
and an 'alias' for static files, but with differing results.  For example, 
suppose that in the application called 'app1', I create a static web page 
that does 3 things:

- displays an image at 'app1/images/button.gif'
- loads a stylesheet from '/app1/includes/default.css'
- posts a form to '/app1/servlet/Controller'

It seems that the images and includes folders are expected to appear in the 
folder 'app1' directly below my appbase, whereas the Controller servlet is 
expected in the 'app1/WEB-INF/classes' folder.  This is different from 
where these folders resided in other servlet containers that did not use 
'WEB-INF'. Apparently 'app1' is a 'script-alias' for servlets, and an 
ordinary 'alias' for static files, with different meanings for each.  The 
problem can be resolved if I use a connector to Apache or IIS, and then 
create the 'alias' for static files in the web server.  But in a standalone 
instance of Tomcat there is no separate alias definition - 'context' is the 
only way to create aliases.

- Am I right about the double-meaning of 'context'?
- Do others experience similar porting issues?
- Is there an online guide that helps app developers select a directory 
structure that is portable across servlet containers?
- Finally, is it the best practice to hard-code the 'context' prefix in 
your application?

Cheers.



         Regards, Bill Claxton [williamc@openasia.net]
         OpenAsia Solutions provides streaming media & payment solutions.
         Check out http://www.openasia.net
........:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message