Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

WEB-INF and web.xml is optional ?

 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Is is required to create WEB-INF, classes, lib and web.xml, if I am deploying only JSP files to web server.

I tried it on tomcat 5.5.7. I have deployed .war file which contain none of the above and only one jsp file ( index.jsp). It is running fine.

So is it required to create above directories and web.xml or it is a tomcat way to execute without it.

Have anybody tried this on application servers other than tomcat.

Thanks
 
Kedar Dravid
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think WEB-INF, web.xml are required only for web applications and invoking servlets, irrespective of the container/application server.
 
AmitVijay AVKulkarni
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Narendra,

What Kedar has written is right.
(1) Basically web.xml is a deployment descriptor for application.
When you have servlets in application you require
1.1) web.xml : Using web.xml developers can
declare initialization parameters for Servlets (ServletConfig)
and initialization parameters for application (ServletContext).
Not only this but some times we also require init parameters for
jsp. So they can be given to jsp using web.xml
We can also configure session timeouts, listerners etc. So
web.xml(deployment descriptor) is required
1.2) WEB-INF -> classes : In this directory we store servlets,java
beans, utility classes. So this also required.
1.3) WEB-INF -> lib : Some times we use third party library i.e.
jar files in our application. That time we keep these lib files
in lib directory. If you dont want to use this directory you can
keep library i.e. jar file in common/lib folder which is under
Tomcat Home Directory.

So if you are using only jsp based application, then you might be having few java beans used with it. So these all directories are required.

~Amit
 
David Bridgewater
author
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlet spec (SRV 9.4) says...

"This specification defines a hierarchical structure used for deployment and packaging purposes that can exist in an open file system, in an archive file, or in some other form. It is recommended, but not required, that servlet containers support this structure as a runtime representation."

That says to me that WEB-INF is highly recommended, but not mandatory. It would be a mean exam question that asked about such fine distinctions though.

Best,

David.
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks all. I assume that the directory structure is optional but highly recommended for exam purpose.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic