aspose file tools*
The moose likes Servlets and the fly likes Jar all the servlets? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Jar all the servlets?" Watch "Jar all the servlets?" New topic
Author

Jar all the servlets?

A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
Hi,

I heard that it is better to jar your servlets rather than keep your classes

in web-inf/classes in a web application....Is it so?

If so whats is the reason...?


Thanks in advance..
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61661
    
  67

Portability, if that's important to you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

I can't see any


[My Blog]
All roads lead to JavaRanch
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61661
    
  67

I will jar up tag libraries into a nice and tidy package. And any classes or servlets that are part of "frameworks" or other systems meant to be shared across multiple web apps. But for servlets that are speicfic to a particular web app, I just put those under WEB-INF/classes.
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
Thank you....

but i dont think that there are no security issues involved if we

dont keep the classes as a jar....Isnt it so?

Regards
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

It is as secure to put them under the classes directory as it is to put them in a jar under the lib directory.
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
Thank you...Satou
dema rogatkin
Ranch Hand

Joined: Oct 09, 2002
Posts: 294
I found classes more convenient for development for some servlet containers, you can replace just a single .class or .properties without jarring. From other side I use signed jar which includes a servlet, a web started app and applet, so see one jar for everything!


Tough in space?, <a href="http://tjws.sf.net" target="_blank" rel="nofollow">Get J2EE servlet container under 150Kbytes here</a><br />Love your iPod and want it anywhere?<a href="http://mediachest.sf.net" target="_blank" rel="nofollow">Check it here.</a><br /><a href="http://7bee.j2ee.us/book/Generics%20in%20JDK%201.5.html" target="_blank" rel="nofollow">Curious about generic in Java?</a><br /><a href="http://7bee.j2ee.us/bee/index-bee.html" target="_blank" rel="nofollow">Hate ant? Use bee.</a><br /><a href="http://7bee.j2ee.us/addressbook/" target="_blank" rel="nofollow">Need contacts anywhere?</a><br /><a href="http://searchdir.sourceforge.net/" target="_blank" rel="nofollow">How to promote your business with a search engine</a>
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
Hi..

______________________________________________________________________

From other side I use signed jar which includes a servlet, a web started app and applet, so see one jar for everything



______________________________________________________________________


Sorry i didnt get this..
sai prasanna
Ranch Hand

Joined: May 02, 2005
Posts: 167
compiler will give preference to load .class files present in classes folder and then it loads .class files present in jar. and there is no difference. but when u deploy u r applicaion from one server to another it will be easy to deploy if ur application is in the form of jar.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61661
    
  67

sai prasanna, JavaRanch is a community of people from all over the world, many of who are not native English speakers. While using abbreviations like "u" instead of spelling out "you" is convenient when text messaging your friends on a cell phone or in a chat room, it presents an extra challenge to those that are already struggling with English. Additionally, such shortcuts may confound automated translation tools that patrons of the Ranch may be making use of.

I would like to ask for your help in making the content of JavaRanch a little easier to read for everybody that visits here by not using such abbreviations.

Please read this for more information.

thanks,
bear
Forum Bartender
sai prasanna
Ranch Hand

Joined: May 02, 2005
Posts: 167
classloader will give preference to load .class files present in WEB-INF/classes and then it loads .class files present in jar. If same name is present in both precedence is given to WEB-INF/classes.

clients cannot access files under WEB-INF directory as it is private to web container. only container can access files under WEB-INF(so security issues doesn't come here)

jar files are easy to distribute
dema rogatkin
Ranch Hand

Joined: Oct 09, 2002
Posts: 294
Which class loader? Why? Easy to distribute in jars? Have you heard about war or ear? All classes you developed have to be stored under classes. All classes you got as is should be stored under lib.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61661
    
  67

Originally posted by dema rogatkin:
All classes you developed have to be stored under classes. All classes you got as is should be stored under lib.


Completely false. You can jar up your own classes if you like and put them in the lib folder.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Bear Bibeault:


Completely false. You can jar up your own classes if you like and put them in the lib folder.


You could also unpack a third party jar file and put the class files under the classes directory. There is usually no reason to do so, but you could.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jar all the servlets?