Monday, August 31, 2009

Standard Directory Layout in TOMCAT

/Apache Software Foundation/Tomcat 6.0/webapps/myapplication/
Place the dynamic content namely html, jsp and images. You can create separate images folder (webapps/myapplication/images) to keep all the images.
/Apache Software Foundation/Tomcat 6.0/webapps/myapplication/WEB-INF/
Place the web.xml file
/Apache Software Foundation/Tomcat 6.0/webapps/myapplication/WEB-INF/lib/
Place all the jar files used by the application
/Apache Software Foundation/Tomcat 6.0/webapps/myapplication/WEB-INF/classes/
Place the dynamic content namely your servlets (java & class files)

In case of servlets any relative reference will always refer to the root directory. Hence the html code "<body background="images/bg.gif" bgcolor="#FFFFFF">" will look for the image in "/images/" folder.

You should map the servlet URL to your servlet using a mapping in the web.xml. This is a virtual mapping, no physical directories need to exist. Tomcat knows that the files it wants will be in WEB-INF/classes or WEB-INF/lib

More information could be obtained HERE & HERE

. Sample application war could be obtained HERE.

No comments:

Post a Comment