title: I'm having problems with my first servlet
body: <p>This is the code to my servlet...</p>
  
  <pre><code>import java.io.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  public class HelloWorld extends HttpServlet {
      private String message;
  
      public void init(){
          message="Hello World";
      }
      public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
          response.setContentType("text/html");
          PrintWriter out = response.getWriter();
          out.println("&lt;h1&gt;"+message+"&lt;/h1&gt;");
      }
  
      public void destroy(){
      }
  }
  </code></pre>
  
  <p>I'm using xampp's tomcat 7</p>
  
  <p>and this is my web.xml file</p>
  
  <pre><code>&lt;web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0"
   metadata-complete="true"&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;HelloWorld&lt;/servlet-name&gt;
      &lt;servlet-class&gt;HelloWorld&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;HelloWorld&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/HelloWorld&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p></p>
  
  <p>My web.xml is in %TOMCAT_HOME%/webapps/ROOT/WEB_INF directory
  and my HelloWorld.class is in %TOMCAT_HOME%/webapps/ROOT/WEB_INF/classes directory.</p>
  
  <p>when I try to run my file from my browser I type</p>
  
  <p><code>http://localhost:8080/HelloWorld</code></p>
  
  <p>in the addressbar
  and the following Servlet exception shows up</p>
  
  <pre><code>type Exception report
  
  message
  
  description The server encountered an internal error () that prevented it from fulfilling this request.
  
  exception
  
  javax.servlet.ServletException: Error instantiating servlet class HelloWorld
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:269)
      org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
      org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
      java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      java.lang.Thread.run(Thread.java:724)
  
  root cause
  
  java.lang.NoClassDefFoundError: HelloWorld (wrong name: com/HelloWorld/HelloWorld)
      java.lang.ClassLoader.defineClass1(Native Method)
      java.lang.ClassLoader.defineClass(ClassLoader.java:752)
      java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
      org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2820)
      org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1150)
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:269)
      org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
      org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
      java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      java.lang.Thread.run(Thread.java:724)
  
  note The full stack trace of the root cause is available in the Apache Tomcat/7.0.21 logs.
  </code></pre>
  
  <p>Please suggest a method to run my app properly...</p>