title: The server encountered an internal error that prevented it from fulfilling this request. J2EE
body: <p>I have a problem with my simply app in J2EE. This is login form. When I type login and password I get </p>
  
  <blockquote>
    <p>The server encountered an internal error that prevented it from
    fulfilling this request.</p>
  </blockquote>
  
  <p>My files:</p>
  
  <h3>Login.java</h3>
  
  <pre><code>package facebookConnection.servlets;
  
  import java.io.IOException;
  import java.io.PrintWriter;
  
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.annotation.WebServlet;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import facebookConnection.classes.Validate;
  
  import java.sql.*;
  
  /**
   * Servlet implementation class Login
   */
  @WebServlet("/Login")
  public class Login extends HttpServlet {
      private static final long serialVersionUID = 1L;
  
      protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          // TODO Auto-generated method stub
          response.getWriter().append("Served at: ").append(request.getContextPath());
      }
  
      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          response.setContentType("text/html;charset=UTF-8");
          PrintWriter out = response.getWriter();
  
          String login = request.getParameter("login");
          String password = request.getParameter("password");
  
          if(Validate.checkUser(login,password))
          {
              RequestDispatcher rs = request.getRequestDispatcher("Welcome");
              rs.forward(request, response);
          }
          else
          {
              out.println("Username or password nieprawidłowy");
              RequestDispatcher rs = request.getRequestDispatcher("index.html");
              rs.include(request, response);
          }
      }
  }
  </code></pre>
  
  <h3>Validate.java</h3>
  
  <pre><code>package facebookConnection.classes;
  
  import java.sql.*;
  
  public class Validate {
      public static boolean checkUser(String login, String password) {
          boolean st = false;
          try {
              //loading drivers for mysql
              Class.forName("com.mysql.jdbc.Driver");
  
              //creating connection with database
              Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/facebook_connections","root","pass");
              PreparedStatement ps = con.prepareStatement("select * from users where login=? and password=?");
              ps.setString(1, login);
              ps.setString(2, password);
              ResultSet rs = ps.executeQuery();
              st = rs.next();
          } catch(Exception e) {
              e.printStackTrace();
          }
          return st;
      }
  }
  </code></pre>
  
  <h3>index.html</h3>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta charset="UTF-8"&gt;
          &lt;title&gt;Login form&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;form action="login" method="post"&gt;
              Login: &lt;input type="text" name="login" /&gt;&lt;br/&gt;
              Password: &lt;input type="text" name="password" /&gt;&lt;br/&gt;
              &lt;input type="submit" value="login" /&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <h3>Welcome.java</h3>
  
  <pre><code>package facebookConnection.servlets;
  
  import javax.servlet.http.HttpServlet;
  import java.io.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  import java.sql.*;
  
  public class Welcome extends HttpServlet {
  
      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          response.setContentType("text/html;charset=UTF-8");
          PrintWriter out = response.getWriter();
          out.println("Welcome user");
      }
  }
  </code></pre>
  
  <h3>web.xml</h3>
  
  <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" 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;facebookConnect&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;Login&lt;/servlet-name&gt;
      &lt;servlet-class&gt;facebookConnection.servlets.Login&lt;/servlet-class&gt;
    &lt;/servlet&gt;
    &lt;servlet&gt;
      &lt;servlet-name&gt;Welcome&lt;/servlet-name&gt;
      &lt;servlet-class&gt;facebookConnection.servlets.Welcome&lt;/servlet-class&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Login&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/login&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Welcome&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/welcome&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Stack Trace</p>
  
  <pre><code>javax.servlet.ServletException: Error instantiating servlet class facebookConnection.servlets.Login
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
      org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
      org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
      org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
      java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      java.lang.Thread.run(Unknown Source)
  root cause
  
  java.lang.ClassNotFoundException: facebookConnection.servlets.Login
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
      org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
      org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
      org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
      java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>Can anybody help me with it? </p>