• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why this error

 
Arun Maalik
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class first extends HttpServlet{

public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException{
PrintWriter out=res.getWriter();
out.println("This is my first servlet");
}
}


Dear sir in the above code if i will not extend the class first from that of HttpServlet and then when i am deploying then i m getting an error message that Noservlet class was added in the war module why sir why? although i am using J2EE server.

with regard

Arun kumar maalik
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need to extend HttpServlet, but you do need to implement Servlet, so that the servlet lifecycle methods are available to be used by the container. But why wouldn't you want to extend HttpServlet - it does a number of useful things that you would have to program yourself otherwise (e.g., the dispatching to the doXYZ methods).
 
Eddy Lee Sin Ti
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which J2EE server you are using? Maybe you can post your web.xml here for further analysis
 
gopinathang nathan
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For me it seems to be, 'I need only accelerator, brake, steering and gear. i dont want anyother things for my car, apart from these'
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic