2016-06-25 23 views
0

私はtomcat 7を実行しています。私はローカルコンピュータ にjspファイルを実行しようとするとmysql dbをビルドしました。HTTPステータス404またはHTTPステータス500を取得します。 すべてq &ここにあり、答えが見つかりませんでした。 混乱のため申し訳ありませんが、私はサーブレットで新しいです....http 500エラーサーブレットjava重複したQ&Aが応答しない

web.xmlの

<?xml version="1.0" encoding="UTF-8"?> 
<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" version="3.0"> 
    <display-name>todolistservlet</display-name> 
    <welcome-file-list> 
    <welcome-file> ToDoListLogin.jsp</welcome-file> 
    <welcome-file>index.html</welcome-file> 
    <welcome-file>index.htm</welcome-file> 
    <welcome-file>index.jsp</welcome-file> 
    <welcome-file>default.html</welcome-file> 
    <welcome-file>default.htm</welcome-file> 
    <welcome-file>default.jsp</welcome-file> 
    </welcome-file-list> 
    <servlet> 
    <servlet-name>login</servlet-name> 
    <servlet-class>Controller</servlet-class> 
    </servlet> 
    <servlet-mapping> 
    <servlet-name>login</servlet-name> 
    <url-pattern>/ToDoListLogin.jsp</url-pattern> 
    </servlet-mapping> 
</web-app> 

ToDoListLogin.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
    pageEncoding="ISO-8859-1"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
<meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
<title>To Do List Login Page</title> 

    <!-- Bootstrap core CSS --> 
    <link href="../css/bootstrap.css" rel="stylesheet"> 

    <!-- Custom styles for this template --> 
    <link href="../css/custom.css" rel="stylesheet"> 
</head> 
<body background="./ToDoListWebPic/icon1.png" style="background-size:62%;"> 

    <% 
    String authentication = (String)request.getSession().getAttribute("authentication"); 


    %> 
     <div class="sign-container"> 
      <div class="container"> 
       <% 
        if (authentication != null && authentication == "false") 
        { 
       %> 
         <div class="alert alert-danger" style="margin-top:0;"> 
          <strong>user id and/or Password Incorrect!</strong> 
         </div> 
       <% 

        } 
       %> 
        <form action="loginServlet" method="get" class="form-signin"> 
        <h1 class="form-signin-heading text-primary">Wellcom to MyToDoList </h1> 
        <h2 class="form-signin-heading text-primary">Please sign in</h2> 

        <label for="inputUserId" class="sr-only">user Id</label> 
        <input type="text" id="inputuserId" name="userId" class="form-control" /> 
        </div> 
        <div> 
        <label for="inputPassword" class="sr-only">Password</label> 
        <input type="password" id="inputPassword" name="password" class="form-control" /> 

        <div> 
         <button class="btn btn-primary btn-lg" type="submit" onsubmit="EncryptorPass.encryptPassword(password)" >Sign in</button> 
         </div> 
         <div> 
         <a href="signup" class="btn btn-default btn-lg">Sign Up</a> 
        </div> 
        </form> 

      </div> <!-- /container --> 

     </div> 
    </body> 
</html>` 

loginServlet.java

package Controller; 

import java.io.IOException; 
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 model.IToDoListDAO; 
import model.ToDoListException; 

/** 
* Servlet implementation class loginServlet 
*/ 
@WebServlet("/loginServlet") 
public class loginServlet extends HttpServlet { 
    private static final long serialVersionUID = 1L; 
    private IToDoListDAO dao = IToDoListDAO.getInstance(); 
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 
     String encryptedPass = null; 

     request.getSession().getAttribute("currentList"); 
     (String)request.getSession().getAttribute("currentItem"); 

     EncryptorPass.encryptPassword(request.getParameter("password")); 
      boolean isUserExists; 
      int user = Integer.parseInt(userId); 
      try { 
       RequestDispatcher rd = null; 
       isUserExists = dao.UserAuthentication(user, pwd); 
       if (isUserExists) 
       { 
// set authentication credentials into session 

         request.getSession().setAttribute("fullName", dao.getAllUsers()); 

        request.getSession().setAttribute("userId", request.getParameter("userId")); 
        response.sendRedirect("home"); 
       } 
       else 
       { 
        request.getSession().setAttribute("authentication", "false"); 
        response.sendRedirect("ToDoListLogin"); 
        rd = request.getRequestDispatcher("/errorpage.jsp"); 
       } 
       rd.forward(request, response); 

      } catch (ToDoListException e1) { 
       // TODO Auto-generated catch block 
       e1.printStackTrace(); 
      } 
     } 

    /** 
    * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) 
    */ 
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 

    } 
} 

答えて

0

あなたは、私はそれがTREID、あなたの迅速な応答のためだけ

@WebServlet("/loginServlet") 

と削除web.xmlファイルから

<servlet> 
    <servlet-name>login</servlet-name> 
    <servlet-class>Controller</servlet-class> 
    </servlet> 
    <servlet-mapping> 
    <servlet-name>login</servlet-name> 
    <url-pattern>/ToDoListLogin.jsp</url-pattern> 
    </servlet-mapping> 
+0

ハイテク タンクを置きます。サーバーを防ぐ内部エラーが発生しました説明 il.ac.hit.samples.sharon.orly.ToDoList.Controller エラーインスタンス化するサーブレットクラスのクラス名 タイプ例外レポート メッセージエラーインスタンス化するサーブレットクラス - 今私は、HTTPステータス500を取得しますそれはこの要求を満たすことからです。 例外 javax.servlet.ServletException:エラーインスタンス化するサーブレットクラスのクラス名 – orlys

+0

私がhi、 は今、私はHTTPステータスを取得する私の答えを – Taha

+0

編集500 - JSPのクラスをコンパイルできません: タイプ例外レポート メッセージできませんへJSPのクラスをコンパイルしてください: 説明この要求を満たすことができない内部エラーがサーバーで発生しました。 例外 org.apache.jasper.JasperException:JSPのクラスをコンパイルできません: 生成されたjavaファイルの[31]行でエラーが発生しました: – orlys

関連する問題