Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we make a web application without using web.xml

 
rahul S Sharma
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • 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..?
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • 1
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64186
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 2
  • Mark post as helpful
  • send pies
  • 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?
 
Punit Jain
Ranch Hand
Posts: 1012
2
  • 0
  • Mark post as helpful
  • send pies
  • 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: 2068
  • 0
  • Mark post as helpful
  • send pies
  • 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: 1012
2
  • 0
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64186
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 1
  • Mark post as helpful
  • send pies
  • 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: 1012
2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just tested in tomcat 6, jsp runs without web.xml..
 
Punit Jain
Ranch Hand
Posts: 1012
2
  • 0
  • Mark post as helpful
  • send pies
  • 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: 2068
  • 0
  • Mark post as helpful
  • send pies
  • 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: 1012
2
  • 0
  • Mark post as helpful
  • send pies
  • 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...
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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: 1012
2
  • 0
  • Mark post as helpful
  • send pies
  • 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..
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic