First time posting to the list. So good to meet you all. :)
> David Wall wrote:
>
> I'm new to Tomcat 3.2.1 and Servlet 2.2 in particular, having just
> come from JRun before webapps made their debut.
>
> I'm struggling with the "best practices" people are using for storing
> their JSPs and Java class files in the webapps directory, while
> storing images and html files in the web server directory root.
>
> For example, in Apache 1.3.14, my document root is htdocs and I am
> putting some files there for serving by apache, like:
>
> htdocs/images/a.gif
> htdocs/images/b.gif
> htdocs/index.jsp <-- empty dummy file workaround so that Apache
> will send a request for "/" to Tomcat's ROOT index.jsp
> htdocs/app.js
> htdocs/app.css
> etc...
I've noticed the same thing with mapping a servlet to an index file (in
my case I mapped it to index.html). I think you have to 'trick' the
webserver into loading a file - if it doesn't find a default file to
load it won't do anything.
> And in my webapps under Tomcat I have:
>
> webapps/ROOT/index.jsp <-- the actual index.jsp served up when I
> enter "/" for apache
> webapps/ROOT/WEB-INF/classes/ (all of my class files needed just by
> the index.jsp file)
> webapps/pub/index.jsp
> webapps/pub/company.jsp
> webapps/pub/news.jsp
> webapps/pub/WEB-INF/classes/ (all the class files needed by 'pub'
> application, even though they are the same as those for ROOT).
>
> My questions are:
>
> 1) This separation of the JSP files from stuff like images,
> javascripts, stylesheets when deployed seems like a pain since they
> need to be in the same directory when I'm using my editing tools (like
> Dreamweaver). Only when I deploy do I need to move the static files
> to the apache locations and the JSPs to the Tomcat webapps area.
> Don't others find this to be a pain, or I am just not doing it right?
>
> 2) The ROOT and pub applications are really not distinct applications,
> only a separation of JSPs and such from the root to a public
> directory. I had this subdirectory structure back before webapps, and
> they were done to organize the JSPs into logical groups like how all
> HTML sites are done. They are not put into separate subdirectories
> because they are separate webapps. Can a single webapp support
> multiple directories, or at least a directory and all subdirectories?
> Perhaps ROOT is just abnormal because everybody wants a page to be
> displayed when they enter your URL like http://myeastside.com/
>
> 3) When Java classes are shared by several webapps, they have to
> appear in each of the webapps' WEB-INF/classes directories. Is that
> what people are doing, or are they JARing them up and then putting
> them in a common location (like Tomcat's 'lib') to be shared by all?
What I found - and prefer - is to put shared JARs in the
$TOMCAT_HOME/lib directory. All of the applications will find them then
and share the same ones. They can also be found/loaded if they are set
in the CLASSPATH (on Unix I have a wrapper script that sets this before
starting Tomcat). One example of something you have to have in the
CLASSPATH and not the lib directory is the j2ee.jar if you access it -
Tomcat won't start with it in the lib directory (probably because it
declares the servlet stuff agina).
> Any thoughts will help. The separation forced by the webapps concept
> seems broken to me since it seems unlikely that web servers and their
> standard document root processing is not going to go away anytime soon
> (we still have PHP, CGI, images, etc. besides JSPs).
>
> David
My understanding of webapps is that it is for autoconfiguring things.
But it is completely optional. I'm exploring Tomcat at work and chose to
intentionaly not use webapps so that we would force ourselves to
explicitly control the configuration of the application. So, that being
said, one thing you could do: in your server.xml file create a context
or a virtual host and map it to the directory where the Apache docRoot
lives. E.g.:
(Forgive any errors, this is from memory)
<Host name="virtualhost">
<Context path="" docBase="c:/htdocs" />
</Host>
Then under c:/htdocs you'll need your WEB-INF directory with it's
web.xml file mapping *.jsp to the JSP engine, etc. I've never done this
with JSPs, but it works with static files and servlets so I don't see
why it wouldn't with them.
Don't know if these are Best Practices, but they're working so far for
me. :)
--
-------------------------------------------
Geoff Lane <[EMAIL PROTECTED]>
'For a list of the ways which technology has
failed to improve our quality of life, press 3.'
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]