File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Servlet 3.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet 3.0" Watch "Servlet 3.0" New topic
Author

Servlet 3.0

Shan Rancho
Greenhorn

Joined: Dec 28, 2012
Posts: 2

How can I write a servlet [using servlet 3.0] without using web.xml in Tomcat 7? Is it possible to deploy a war without having a web.xml ?

Thanks
Shan


Shan

Sun Certified Java Progammar, Sun Certified Web Component Developer
Ivan Jozsef Balazs
Rancher

Joined: May 22, 2012
Posts: 867
    
    5
Apache Tomcat Versions


Servlet/JSPc Apache Tomcat version Actual release revision Minimum Java Version
3.0/2.2 7.0.x 7.0.34 1.6
2.5/2.1 6.0.x 6.0.36 1.5
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41149
    
  45
Can you tell us what prompted this question? (I'm not sure how Ivan's answer is supposed to help.)


Ping & DNS - my free Android networking tools app
Ivan Jozsef Balazs
Rancher

Joined: May 22, 2012
Posts: 867
    
    5
Ulf Dittmer wrote:I'm not sure how Ivan's answer is supposed to help.


I gave the hint to the version data sheet about how the Tomcat version and the supported Servlet version match.
For example Apache Tomcat version 7.0 supports Servlet API 3.0.

I must admit to have tried Apache Tomcat version 7.0 so that the servlet was not declared in web.xml but was declared with annotations and it worked.
There was a web.xml however with welcome file and resource information, so I did not try this feature with a completely missing web.xml.
Shan Rancho
Greenhorn

Joined: Dec 28, 2012
Posts: 2

With the new Servlet specification 3.0 and Java 5 (Annotation) introduction we can completely discard web.xml for particular servlet. My question/doubt is how container (Tomcat 7) resolve the servlet with annotations. Also can we deploy a WAR having one HelloworldServlet servlet without web.xml [using Tomcat Server 7.x]
gurunath pai
Greenhorn

Joined: Dec 10, 2012
Posts: 13

Please check this link for a glimpse of servlet 3.0 http://java.dzone.com/articles/checking-out-what-new-servlet


“Anyone who has never made a mistake has never tried anything new.” ― Albert Einstein
Ivan Jozsef Balazs
Rancher

Joined: May 22, 2012
Posts: 867
    
    5
It is not that difficult to try it.

As said, I tried it and the servlet worked even though not declared in web.xml but only with the annotation.

What I have not tried yet it is whether a web application works without any web.xml at all.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Servlet 3.0
 
Similar Threads
servlet doesn't invoke (page not found displayed)
Can we make a web application without using web.xml
Servlets access directly.
Registering a Servlet at runtime
Servlet loading on application startup