Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Where to put the servlet.jar

 
Bob Robertson
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am curious to know about how to manage my local development of a webapp and the Tomcat server I'm deploying to.

I'm using Netbeans 4.1 where I include the servlet api so those classes are available to me in my project. However, I don't think I should have to include it in my app's lib directory seeing as how Tomcat will already be running that for me. Do I just need to make sure that my ant deploy task omits that jar from the build or do I need to have the api in both the Tomcat lib and the webapp's lib?

Thanks in advance!

br
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the IDE's forum where the Netbeans guru's hang out.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should most definitely not make a copy of the jar file in your web app's folder. Leave it in the Tomcat common lib and only there.

You do not want to get into a situation where the container is picking up an obsolote jar file that was copied about.
 
Bob Robertson
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, not that this is really an IDE question, but whatever... probably more an ANT topic, but definitiely servlets... when I'm in the project whether working in notepad or whatever, I need to tell ANT what to do. It needs to know what libraries to use when compiling. However, my local enviornrment maybe windows with a local version of Tomcat, but I'm deploying to a Linux box where I have no visibility outside of dropping in the war file to a folder. I could just set the classpath to the local tomcat instance's servlet.jar but that doesn't seem right. Plus, how will that affect my deployment? Do I need to configure some env variable to abstract this?

I need my project to compile so I can build the WAR, but I don't want to include a servlet.jar in my lib folder of my webapp. How do I organize my project make sure I avoid conflicts? And will Tomcat by default override whatever servlet.jar I've specified with its own?

Thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bob Robertson:
I need my project to compile so I can build the WAR, but I don't want to include a servlet.jar in my lib folder of my webapp


Correct. If you are building on a different system than Tomcat is installed upon, you'll need a local copy of the APIs to build against. Make sure that the file is in the classpath of the compile, but not somewhere where it will become part of the generated war file.

If the compile occurs on the same system, just add Tomcat's copy of the API to your compilation classpath.

Originally posted by Bob Robertson:
And will Tomcat by default override whatever servlet.jar I've specified with its own?


Tomcat will have a copy of the API on its own classpath -- you don't need to worry about it.
[ December 29, 2005: Message edited by: Bear Bibeault ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic