I am a beginner to advance java and since am learning servlet am getting some weird error in my servlet. I am trying to get the method name and this is the code which i wrote down
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class NewServlet extends HttpServlet {
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
} finally {
out.close();
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// processRequest(request, response);
response.setContentType("text/html");
PrintWriter out= response.getWriter();
out.println("<html><body>");
out.println("your method was "+ request.getMethod());
out.println("</body></html>");
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// processRequest(request, response);
response.setContentType("text/html");
PrintWriter out= response.getWriter();
out.println("<html><body>");
out.println("your method was "+ request.getMethod());
out.println("</body></html>");
}
public String getServletInfo() {
return "Short description";
}
}
when i try to run this servlet am getting "Class newservlet neither have a main method nor it is the servlet specified in web.xml". Though i added this servlet named newservlet in web.xml but am continued with getting this error and i think so servlet do not have any main method. So please i need help!!!!!