Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can we use annotations instead of web.xml?

 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only with Servlets 3.
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that to be the case, but the Servlet Spec has the final say.
 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay...
thank you...
 
varun Dosapati
Ranch Hand
Posts: 31
Java Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

@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
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic