• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Servlet package and Tomcat Question  RSS feed

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Art Smith
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>


 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!