File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes @WebServlet annotation is not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "@WebServlet annotation is not working" Watch "@WebServlet annotation is not working" New topic

@WebServlet annotation is not working

suryakant kachhi

Joined: Nov 23, 2012
Posts: 2

can any buddy tell me that i have annotation with @WebServlet but is not working

public class NewServlet extends HttpServlet {

please tell me where is the problem???
Jelle Klap

Joined: Mar 10, 2008
Posts: 1951

Hi, and welcome to JavaRanch!

Assuming this isn't the entire Servlet class, it's hard to say what the problem is. Does the servlet "work" if you add it to the web.xml deployment descriptor insted of using annotations? Could you give use some more information about the servlet container / application server you're deploying to and what you're deployment structure looks like?

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
suryakant kachhi

Joined: Nov 23, 2012
Posts: 2

actually its working when mapping is done in web.xml file but i want to do it with the annotation so where is i wrong
Ankit Dan
Ranch Hand

Joined: Aug 31, 2012
Posts: 47

@WebServlet annotation is there since Servlet version 3.0...check your version as well...this might be the case
I agree. Here's the link:
subject: @WebServlet annotation is not working
It's not a secret anymore!