aspose file tools*
The moose likes Servlets and the fly likes servlet.jar for each webapp? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet.jar for each webapp?" Watch "servlet.jar for each webapp?" New topic
Author

servlet.jar for each webapp?

Barbara Norway
Ranch Hand

Joined: Sep 30, 2003
Posts: 150
Hello,
I'm just starting out with Tomcat, JSP, and servlets as you'll be able to tell from my questions:
I have a Tomcat server running with an application under the examples directory such that I type http://ourfineschool.edu:8088/examples/name_of_app/admin
It works fine. Now I need to add another app which I hoped to access with the same URL except I would replace the "name_of_app" with the second apps name. Things are working fairly well except I get an error that it can't find the application's servlet (it's looking at the default port 80 and URL is wrong).. One of my question is:
Should there be more than one "servlet.jar"? I already have one for first app in common/lib but it's different than the new one the developer gave me. Just to clarify, I'm not talking abot the application specific .jar but the "generic " one. I'm pretty confused because I have looked through our server and there are a number of "false starts" wherein someone installed the first applications files in many places and so there are about a dozen web.xml files. One that affects the functioning of the server is in this directory:
/usr/local/tomcat/webapps/examples/WEB-INF
When I try to add information for the new app it "breaks" the server for the old app. I tried looking in files in various directories for a reference to the name of the first app to see how it was done but there isn't a mention that I can find. maybe it was installed as "ROOT" or the default app?
Obviously I'm lost . Any help would be greatly appreciated!!!
Barbara


farmkitty
Eelco den Heijer
Ranch Hand

Joined: Jan 17, 2002
Posts: 61
Hi,
From your posting I can more or less detect that a number of things are not quite right, but it's difficult to pinpoint them.
Things I think should be fixed anyway:
1. package a web application in a WAR file (Web archive), each having its own web context, web.xml and servlet classes. Deploy each WAR separately. You can add a number of servlets in a web archive, you should declare them in the web.xml (this is the descriptor of your web app).
2. Clean up stuff you're not using. It looks like you have some old junk floating around your Tomcat installation; this may cause some of the errors you are experiencing.
Hope this helps.
Eelco


== <br />Rgrds,<br />Eelco<br /> <br />SCJP, SCJD, SCBCD, SCWD, SCEA
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Generally speaking, web applications are referenced by the first item after the domain. I think you're in for a world of hurt if you try to 'shoehorn' applications into the same directory.

http://ourfineschool.edu:8088/examples

I would take 'name_of_app' out of the examples app, and refer to it like:

http://ourfineschool.edu:8088/name_of_app
http://ourfineschool.edu:8088/name_of_other_app

This is a highly recommended way of doing things.

servlet.jar -> contains the servlet API classes (like HttpServlet and HttpServletRequest). There should only ever be a single instance of this jar file (in common/lib). As for 'different' servlet.jar files... your developer should not be giving you one. It's not required. There are different versions of the servlet spec, for which there exist different servlet.jar files.. but as long as your app was compiled with version 'n' of servlet.jar, then a jar file of n+x should work (but not n-x). This is standard "backwards compatible" behaviour.

As for "When I try to add information for the new app it "breaks" the server for the old app."

The 'server' is configured in CATALINA_HOME/conf/server.xml. Look in here for <Context> tags. Each <Context> will equal one configured application. And yes, the /examples one should be there. ROOT *is* the default app, which is why you can just say "http://ourfineschool.edu:8088/" and get that app (you get the default when you don't specify the web-app in the browser).

Tomcat is smart enough to 'autoconfigure' any application that is dropped (in WAR format) into its CATALINA_HOME/webapps directory. It will also autoconfigure any unpacked directory under webapps. One requirement here is that the directory (and the WAR) must contain a non-empty WEB-INF/web.xml file. A web.xml file with nothing but <web-app /> should be enough. For auto-configured apps, the name of the app is the name of the folder or WAR file (without extension).

Hope that helped, but ask more questions if not!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlet.jar for each webapp?