This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
The servlet goes into WEB-INF/classes. No need to tinker with the classpath. Basically, it your servlet is called "pack.MyServlet" (where "pack" is the package name), try the following:
1. Compile the servlet and put it into "classes", so that you get: WEB-INF/classes/pack/MyServlet.class (Pitfalls: make sure to maintain the "pack" directory, and also note that it's the compiled ".class", not the ".java" source).
2. Locate the file "WEB-INF/web.xml" , and add a "servlet-mapping" to it. A simple "web.xml" looks like:
In your case, if you use the existing ROOT, you'll need to add those entries to the existing web.xml, which already has some entries. Just note the order: first all "servelt" tags, then all "servlet-mappings", so it'll be something like: < servlet > ... < servlet > ... < servlet-mapping > ... < servlet-mapping > ...
3. Start up tomcat (to be on the safe side, make sure Tomcat's not running while you do the above changes. Start it only after everything's ready. It's an overkill, but it'll do for starters).
Hope this helps... if not, could you please quote the exact error message issued by tomcat ?
Yong Ming Wai
Joined: Aug 31, 2004
Thanks for advice...
After few changes..i managed to get it done. Unfortunately,new problems arise along.. My system has alot of folders which contain lots of servlets..(.class) do i have to declare all of them and map it in web.xml one by one..
my login.jsp will post value to login.class(login folder) which will import util.class(in system folder) to use DCconnect() to verify the login..then..if valid.. login.class will call welcome.jsp
do i have to.. write... < servlet > ... < servlet > ... < servlet-mapping > ... < servlet-mapping > ... for all the servlet? if kinda of troublesome,rite?
Joined: Nov 13, 2002
Good question... I know of 2 workarounds for it (but there could be more):
1. Tomcat is supposed to have an "invoker servlet". Haven't used it much, but you should be allowed to add the following to "web.xml":
You'll probably find it ugly (lots of if's inside the servlet, and no obvious gain), but it's worth mentioning since that's the idea behind the popular Struts framework (of course, Struts is much smarter than a bunch of silly if's... on the other hand, it still makes you do lots of XML configuration).