HTTP状态404.说明请求的资源不可用

时间:2014-12-09 19:30:52

标签: java eclipse tomcat

我在这里有一个页面。当我点击提交按钮时,我得到404页面说:

HTTP Status 404 - /Email/EmailGet


type Status report

message /Email/EmailGet

description The requested resource is not available.


Apache Tomcat/7.0.47

代码:

    <%@ 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">
<title>Insert title here</title>
</head>
<body>
    <form action="EmailGet" method="GET">
        Email: <input type="text" name="email"> <br> Password: <input
            type="password" name="password"> <br> <input
            type="submit" value="Submit">
    </form>
</body>
</html>

这是EmailGet代码:

package email;

import java.io.IOException;

import javax.mail.Session;
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 javax.servlet.http.HttpSession;

/**
 * Servlet implementation class Controller
 */
@WebServlet("/EmailGet")
public class EmailGet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public EmailGet() {
        super();
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // Gets the entered email and password

        String username = request.getParameter("email");
        String password = request.getParameter("password");

        //Creates the session and sets the session attributes

        HttpSession session = request.getSession();
        session.setAttribute("username", username);
        session.setAttribute("password", password);

        RequestDispatcher dispatcher;

        //Calls the setCredentials method to check if entered credentials are valid

        boolean result = SendSMTPMail.setCredentials(username, password);

        //if valid, forwards to send page
        if (result == true) {
            dispatcher = request.getRequestDispatcher("send.jsp");
            dispatcher.forward(request, response);      
        }

        //if not valid, forwards to index page with error message displayed
        else {
            dispatcher = request.getRequestDispatcher("indexerror.jsp");
            dispatcher.forward(request, response);      
        }

    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
    }


}

有什么想法吗?它过去很好地转发页面,但现在似乎没有工作。

每个jsp页面都可以单独运行,它只是不起作用的转发。

1 个答案:

答案 0 :(得分:0)

看来。 。 。请求的页面不存在。我不知道你的文件的名字,所以我只能猜到你在某个地方有一个错字,试着查看你的网址栏并检查这是否真的是你想要的网址。