Here is the java servlet interface
•
Java
I'm new to Java
I'm creating a servlet and getting the wrong interface here
Can you make me understand this problem?
I'm using IntelliJ 14
My servlet code is as follows: –
package ERPdetector; /** * Created by Sinha on 12/15/14. */ import javax.servlet.http.*; import javax.servlet.*; import java.io.*; public class ErpServlet implements HttpServlet { public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException { res.setContentType("text/html"); PrintWriter pw=res.getWriter(); String dropdown=req.getParameter("dropdown"); pw.println("You Requested for "+dropdown); pw.close(); } }
Thank you in advance
Solution
Httpservlet is an abstract class, not an interface - a servlet is an interface, but you rarely implement it directly
Just change this:
public class ErpServlet implements HttpServlet {
to
public class ErpServlet extends HttpServlet {
You should be fine
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码