• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can we make a web application without using web.xml

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Folks,
In a project suppose we have only jsp pages not even a single servlet . Do we still need to add web.xml in our project..?
 
Ranch Hand
Posts: 2108
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. The java servlet specification requires it.

Jsp IS a servlet. At the time the jsp involved is requested, it is first converted into a servlet, compiled, and then executed, to return the reply.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

rahul S Sharma wrote:In a project suppose we have only jsp pages not even a single servlet .


That would be a project following very poor practices. Why would even contemplate such a thing?
 
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Servlet 3.0, you can also use annotations instead of web.xml.
here you can read about them..
Here
 
Jesus Angeles
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Punit Jain wrote:In Servlet 3.0, you can also use annotations instead of web.xml.
here you can read about them..
Here



My post above is wrong, as pointed out by Punit.

You can have a war file without a web.xml, if you are using jsps only.
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
as far as i know after scanning the class, it servlet container found annotation it will generate web.xml by it's own.
and also servlet 3.0 support these annotataions only,
@WebServlet
@WebServletContextListener
@ServletFilter
@InitParam

if you want to do something more with web.xml, (ie. security roles etc).
you have to do it explicitly in web.xml.

please correct me if i am wrong.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm far less concerned with whether there's a web.xml or not than with the presences of only JSPs. That means that everything, views, model, and controllers, are implemented using JSPs and that would be a very very bad thing!
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just tested in tomcat 6, jsp runs without web.xml..
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just test annotations in servlet 3.0 and tomcat 7,
servlet runs successfully, but no web.xml is created.
annotation i used:

 
Jesus Angeles
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I checked the 3.0 specs for servlet, and I cant find any statement saying that the container is required to generate a web.xml. If there is no such requirement, it is up to each container implementation if it will generate a web.xml or not.
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I checked the 3.0 specs for servlet, and I cant find any statement saying that the container is required to generate a web.xml. If there is no such requirement, it is up to each container implementation if it will generate a web.xml or not.


perhaps...
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesus Angeles wrote:I checked the 3.0 specs for servlet, and I cant find any statement saying that the container is required to generate a web.xml. If there is no such requirement, it is up to each container implementation if it will generate a web.xml or not.



It's not the server which generates the web.xml. The application developer is expected to create the web.xml. Starting Servlet 3.0, the web.xml is optional which means that the application developer need not create it, if he doesn't require it.

 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


It's not the server which generates the web.xml. The application developer is expected to create the web.xml. Starting Servlet 3.0, the web.xml is optional which means that the application developer need not create it, if he doesn't require it.



okay..
thanks for clarification Jaikiran Pai..
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic