Saturday, August 18, 2012

Deploying Web Applications to Tomcat


http://oreilly.com/java/archive/tomcat.html

Some control files...

/etc/tomcat7/Catalina/localhost/examples.xml
/usr/share/tomcat7-examples/examples/WEB-INF/web.xml

url-pattern will map to servlet-name


http://cs.calstatela.edu/~abbott/Courses/CS_320b/Running%20a%20Servlet%20under%20Tomcat.html


Run a Servlet

  1. One of the links in the file http://localhost:8080/examples/servlets/index.html is to ../servlet/HelloWorldExample. On first glance, this looks like it should be referring to a file at %TOMCAT_HOME%/webapps/examples/servlet/HelloWorldExample. But there is no such file. In fact, there is no such directory as%TOMCAT_HOME%/webapps/examples/servlet/.
  2. Instead, by convention, a reference to what appears to be a servlet directory at the top level of a mapped webapp address means: execute the indicated servlet. In this case, execute the servlet called HelloWorldExample.
  3. Servlets are simply .class files, i.e., compiled .java files.
  4. Servlet files are stored in the WEB-INF/classes subdirectory of the main web application directory. In this case the .class files for the examples web app is stored in%TOMCAT_HOME%/webapps/examples/WEB-INF/classes.
So when the user requests
http://localhost:8080/examples/servlet/HelloWorldExample
Tomcat runs
%TOMCAT_HOME%/webapps/examples/WEB-INF/classes/HelloWorldExample.class


No comments:

Related Posts Plugin for WordPress, Blogger...