Hi, All
I am new to servlets, i wrote one servlet file, it is compiling well.but if i try to run
this servlet. Its giving Error like: "Exception in thread "main" java.lang.NoSuchMethodError: main".
is their any problem with classpath, already i set servlet.jar file as a classpath.So let me know any thing requires.

package hall;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet {
  public void doGet(HttpServletRequest request,
                    HttpServletResponse response)
      throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    out.println("Hello World");
  }
}

You run a servlet through an application server, not from the command line. Do you have an application server? Tomcat, WebSphere AS, Bea WebLogic, Sun AS, etc, etc.

Once you have one (you can download and use Tomcat for free), read its documentation to find out how you deploy an application, then deploy your servlet, and try to access it with the browser.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.