Forums Register Login

jar Archive and Servlets

+Pie Number of slices to send: Send
Hi!
Is it possible to run my Servlet, whose classes are in a jar archive (including the class with the doPost method)? If yes, how have I to configure the web.xml file (I'm using tomcat)?
Thanks,
Nick
+Pie Number of slices to send: Send
Why don't you:
(1) Create a WAR file for your project (in whatever way your IDE provides for that purpose) and
(2) Deploy that WAR file to Tomcat in whatever way is appropriate for that servlet engine?
+Pie Number of slices to send: Send
Hi Nick,
Regardless of how you deploy your web app (war file or not), if the jar file containing the servlet is placed within the WEB-INF/lib folder of your web app, it will be in the classpath of the app.
In your web.xml you would create servlet and servlet mapping declarations as approriate. Or is it the format of these declarations that has you stumped? If that's the case, here's a simple example lifted from one of my web.xml files:

This is just one way to deal with a servlet. Your needs may vary. Point is, the entries in the web.xml are orthogonal to whether your servlet is in a jar or not, as long as it is in the classpath.
hth,
bear
[ June 20, 2003: Message edited by: Bear Bibeault ]
+Pie Number of slices to send: Send
P.S. One of the bartenders is soon going to ask you to change your name, as "Nick Someone" does not conform to Ranch policies. Why not do them a favor and beat them to the punch?
+Pie Number of slices to send: Send
Thanks for your response. But I think i still don't understand it. I have a jar File named "mypackage.jar". I deploy it in the web-inf/lib folder. What have I to change now in the web.xml file, if the class which shall be mapped to a URI is in this jar-File?
Nick
Whats wrong with my nick? ;-)
+Pie Number of slices to send: Send
No changes. It will "just work"

And yah, the official "change your name" request. Please.
+Pie Number of slices to send: Send
It doesn't work. There only comes this error message:
java.lang.IllegalArgumentException: Not an HTTP URL:java.io.IOException: HTTP response code: 500
+Pie Number of slices to send: Send
Sounds like your URL is malformed.
Further responses will be available when your name is changed to conform to Ranch standards. Not to be a bully, but you have now been officially asked.
bear
[ June 21, 2003: Message edited by: Bear Bibeault ]
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 724 times.
Similar Threads
How can make .war file for IBM websphere configurable?
How to create a JAR along with oracle thin
Invoke a Servlet from a WebService
configuring my application to Tomcat 5.5
configuring my application to Tomcat 5.5
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 22:01:39.