aspose file tools*
The moose likes Servlets and the fly likes can we use annotations instead of web.xml? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "can we use annotations instead of web.xml?" Watch "can we use annotations instead of web.xml?" New topic
Author

can we use annotations instead of web.xml?

Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 1000
    
    2
i don't know weather it can be done or not,
but is it possible to write servlet without DD, i mean can we use annotations instead of deployment descriptor to write a servlet?
if so, how??
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61229
    
  66

Only with Servlets 3.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

How does that order filters? With web.xml you can determine the order filters are called in, but I didn't see anything about that in the WebFilter annotation.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 1000
    
    2

How does that order filters? With web.xml you can determine the order filters are called in, but I didn't see anything about that in the WebFilter annotation.

i also don't know how to do that with annotations, the only thing which i have tried is url-pattern.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61229
    
  66

I haven't played around with Servlets 3 any yet -- it's hard enough to get clients to use Tomcat 6, no way are they moving to 7 yet.

But, I think I read somewhere that if stuff like order is important, you need to fall back to using the deployment descriptor for those elements.
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 1000
    
    2
Thank you bear bibeault.
so to be short and precise, we can't do all things with annotations, which we can do with deployment descriptor..
also we can't do such things like security concerns (security roles etc), with annotations, i think..
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61229
    
  66

I believe that to be the case, but the Servlet Spec has the final say.
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 1000
    
    2
okay...
thank you...
varun Dosapati
Ranch Hand

Joined: Nov 18, 2010
Posts: 30


@Rob: About the @WebFilter I think we can say the container through pro grammatically. else it is up to container to choose.(Any one Please correct me if I am wrong).

@paul: I started reading the servlet 3 spec. I believe the security concerns like(security roles) can be done through programming which I believe is the feature in servlet 3
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

Bear Bibeault wrote:But, I think I read somewhere that if stuff like order is important, you need to fall back to using the deployment descriptor for those elements.

I guess that makes sense. It's like specifying a global interceptor for EJBs. The only way to do that without adding the @Interceptors annotation to each and every EJB is to put it in the deployment descriptor.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can we use annotations instead of web.xml?