0

少しだけ助けが必要です。

小さなテスト プロジェクトを作成しようとしましたが、このエラーで立ち往生しています。すべての JAR ファイルと JSP を適切に配置します。

The requested resource (/LibrayManagement/list_of_books_available.jsp) is not available

以下はjspコードです:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!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">
<title>Library</title>
</head>
<body>
<form action="Listofbooksaction" method="post">

<h3>List of books available</h3>

<c:forEach var = "list" items = "${requestScope.BooksList}">

<c:out value = "${list[0]}">

</c:out>

</c:forEach>

<input type= "submit" value = "get list">
</form>
</body>
</html>

以下は Action クラスのコードです:

import java.sql.* ;
import java.io.IOException;
import java.sql.ResultSet;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**

public class Listofbooksaction extends HttpServlet {
    private static final long serialVersionUID = 1L;



    String url = "list_of_books_available.jsp";
    public Listofbooksaction() {
        super();

    }


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub



    }

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

        ConnectionsList c = new ConnectionsList() ;


        try {
            Statement St = c.createconnection();
            ResultSet Rs = St.executeQuery("Select * from books_list") ;
            System.out.println(Rs);

            ArrayList<String> Books_List = new ArrayList<String>();

            while(Rs.next())
            {
                Books_List.add(Rs.getString(1));
            }

            request.setAttribute("BooksList", Books_List);

            response.sendRedirect(url);

        } catch (SQLException e) {

            e.printStackTrace();
        }




    }

}

エラースタックトレース:

java.lang.IllegalStateException org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:4‌​35) Listofbooksaction.doPost(Listofbooksaction.java:62) javax.servlet.http.HttpServlet.service(HttpServlet.java:637) javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

4

0 に答える 0