title: Servlet class not found exception
body: <p>I'm trying to write a very simple servlet, and a HTML form's action uses the servlet.</p>
  
  <p>This is my HTML form:</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Upload Video&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;%
      Object userSession = session.getAttribute("email");
  
  if(userSession == null)
  {
      out.println("Welcome to the MyTube, you are not logged in. &lt;br /&gt;&lt;br &gt;");
      out.println("Please click the following to login: &lt;a href=\"login.jsp\"&gt;here&lt;/a&gt;");
      out.println("Or Click this to register: &lt;a href=\"register.jsp\"&gt;here&lt;/a&gt;");
  }
  else
  {
      out.println("&lt;form action=\"servletClass\" method=\"post\" enctype=\"multipart/form-data\"&gt;");
      out.println("&lt;input type=\"file\" name=\"file\" /&gt;");
      out.println("&lt;input type=\"submit\" /&gt;");
      out.println("&lt;/form&gt;");
  }
  
  %&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is my servlet class:</p>
  
  <pre><code>public class uploadServlet extends HttpServlet
  {
      String awsAccessKey = "WHOOOPS";
      String awsSecretKey = "WHOOOPS/YWPkmKfe";
      AWSCredentials awsCredentials = new AWSCredentials(awsAccessKey, awsSecretKey);
  
      protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException 
      {
          boolean isMulti = ServletFileUpload.isMultipartContent(request);
          if (isMulti) 
          {
              ServletFileUpload upload = new ServletFileUpload();
  
              try 
              {
                  FileItemIterator iter = upload.getItemIterator(request);
                  while (iter.hasNext()) 
                  {
                      FileItemStream item = iter.next();
                      InputStream inputStream = item.openStream();
                      if (item.isFormField()) 
                      {
  
                      } 
                      else
                      {
                          String fileName = item.getName();
                          if (fileName != null &amp;&amp; fileName.length() &gt; 0) 
                          {
                              S3Service s3Service = new RestS3Service(awsCredentials);
  
                              S3Object fileObject = new S3Object();
                              fileObject.setDataInputStream(inputStream);
                              fileObject.setContentLength(Integer.parseInt(request.getHeader("Content-Length")));
                              s3Service.putObject("vidvidbucket", fileObject);
  
                              //read stream of file uploaded
  
                              //store as a temporary file
  
                              //upload the file to s3
                          }
                      }
                  }
              } 
              catch (Exception e) 
              {
  
              }
          }
  
          response.sendRedirect("location of the result page");
      }
  }
  </code></pre>
  
  <p>This is my web.xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"&gt;
    &lt;display-name&gt;MyTubeServer&lt;/display-name&gt;
  
    &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
      &lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.html&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.htm&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.jsp&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
  
    &lt;servlet&gt;
      &lt;servlet-name&gt;servletClass&lt;/servlet-name&gt;
      &lt;servlet-class&gt;uploadServlet&lt;/servlet-class&gt;
    &lt;/servlet&gt;
  
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;servletClass&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/servletClass&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>This is the eclipse settings:</p>
  
  <p><img src="https://i.stack.imgur.com/dXLIF.png" alt="enter image description here"></p>
  
  <p>I looked at other posts that you should also include the java file at your WEB-INF folder. But I keep getting classNotFoundException.</p>
  
  <p>EDIT: The stacktrace indicates that the uploadServlet cannot be found, so I'm confused.</p>
  
  <p>EDIT 2: After setting XML file for the servlet-class to servletClass.uploadServlet instead of servlet-class, but now I get the requested source, (X/Location%Of%The%File%Is%Not%Found) without any exceptions</p>
  
  <p><img src="https://i.stack.imgur.com/mHrV2.png" alt="enter image description here"></p>