wood burning stoves*
The moose likes Servlets and the fly likes Servlet package and Tomcat Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet package and Tomcat Question" Watch "Servlet package and Tomcat Question" New topic
Author

Servlet package and Tomcat Question

Art Smith
Ranch Hand

Joined: Dec 12, 2000
Posts: 33
I use JBuilder Foundation to edit and compile my servlets. Jbuilder creates a package for each project and places all of the classes for that project in the package.
Do I have to include tha package path under my classes dir with Tomcat. In other words:
// Top few lines from my Servlet
package servlets;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
// Entry from my web.xml file
<servlet>
<servlet-name>
TestServlet
</servlet-name>
<servlet-class>
TestServlet
</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>
TestServlet
</servlet-name>
<url-pattern>
/TestServlet
</url-pattern>
</servlet-mapping>
// Context as defined in my server.xml file
<Context path="/hallanet"
docBase="webapps/hallanet"
crossContext="false"
debug="0"
reloadable="true" >
</Context>
Directory Structure under webapps in tomcat:
D:\ApacheGroup\Tomcat\jakarta-tomcat-3.2.1\webapps\hallanet\Web-inf\classes
How do I corrlate these files, packages and paths so that MY servlets will run.
NOTE: The Tomcat examples; servlets and JSP's work just fine.
Art

Arthur Smith<br />SCJP2 - SCWCD
Roopa Bagur
Ranch Hand

Joined: Nov 03, 2000
Posts: 267
Whatever you have done loos fine to me.
What message are you getting when you run your servlet?
Originally posted by Art Smith:
I use JBuilder Foundation to edit and compile my servlets. Jbuilder creates a package for each project and places all of the classes for that project in the package.
Do I have to include tha package path under my classes dir with Tomcat. In other words:
// Top few lines from my Servlet
package servlets;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
// Entry from my web.xml file
<servlet>
<servlet-name>
TestServlet
</servlet-name>
<servlet-class>
TestServlet
</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>
TestServlet
</servlet-name>
<url-pattern>
/TestServlet
</url-pattern>
</servlet-mapping>
// Context as defined in my server.xml file
<Context path="/hallanet"
docBase="webapps/hallanet"
crossContext="false"
debug="0"
reloadable="true" >
</Context>
Directory Structure under webapps in tomcat:
D:\ApacheGroup\Tomcat\jakarta-tomcat-3.2.1\webapps\hallanet\Web-inf\classes
How do I corrlate these files, packages and paths so that MY servlets will run.
NOTE: The Tomcat examples; servlets and JSP's work just fine.
Art

Scott Stirling
Greenhorn

Joined: Mar 05, 2001
Posts: 24
Yes, you have to include the package under the WEB-INF\classes dir.
You also have to define the servlet using its fully qualified class name, so TestServlet should be:
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>servlets.TestServlet</servlet-class>
</servlet>

Scott Stirling<BR>Author of <A HREF="http://www.amazon.com/exec/obidos/ASIN/067231939X/ref=ase_electricporkchop/107-2476442-4883722" TARGET=_blank rel="nofollow">Java Server Pages Application Development</A>
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
D:\ApacheGroup\Tomcat\jakarta-tomcat-3.2.1\webapps\hallanet\Web-inf\classes
I would use either the web.xml or the server.xml not both.
I prefer the older way of server.xml, personally.
Also, to understand this better, pl. refer to this article
where they walk you thru such an example
.
Do I have to include tha package path under my classes dir with Tomcat
Yes you do have to.
So your dir structure should be:
webapps/hallanet/WEB-INF/classes/servlets/TestServlet.class
regds.
- satya

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Art Smith
Ranch Hand

Joined: Dec 12, 2000
Posts: 33
Scott - You win the prize. That was it! This single line of code:
servlets.TestServlet
Solved my problems.
THANKS A LOT!
Art
Originally posted by Scott Stirling:
Yes, you have to include the package under the WEB-INF\classes dir.
You also have to define the servlet using its fully qualified class name, so TestServlet should be:
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>servlets.TestServlet</servlet-class>
</servlet>

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet package and Tomcat Question
 
Similar Threads
Servlet not being called
Webapp works locally, but not on Server
HTTP Status 404 servlet error ("The requested resource is not available")
Http Error 500
Servlets with Tomcat 4