0

I've got a page here. When I click the submit button, I get the 404 page saying:

HTTP Status 404 - /Email/EmailGet


type Status report

message /Email/EmailGet

description The requested resource is not available.


Apache Tomcat/7.0.47

Code:

    <%@ 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>

Here's the EmailGet code:

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
    }


}

Any ideas? It used to forward the page fine, but seems not to be working now.

Each jsp page runs fine individually, it's just the forwarding that isn't working.

John
  • 1
  • 1

1 Answers1

0

It seems. . . that the requested page does not exist. I don't know the names of you files, so i can only guess that you have a typo somewhere, try to check your url bar and check if this is really the url you wanted.

Vincent
  • 156
  • 1
  • 9
  • Would http://localhost:8080/Email/EmailGet?email=&password= be the same page as http://localhost:8080/Email/send.jsp/? – John Dec 09 '14 at 19:40
  • @John No. Try to change the `
    ` to `
    `
    – Vincent Dec 09 '14 at 19:44
  • I need to run the doGet in the EmailGet.java class after pressing submit though. The EmailGet.java code (posted above) should forward my page onto send.jsp, and I can't see why it's not – John Dec 09 '14 at 19:47
  • try `@WebServlet(value="/EmailGet", name="[script name]")` – Vincent Dec 09 '14 at 19:53
  • @John forgot to mention you -_- – Vincent Dec 09 '14 at 20:09
  • Bleh. I figured everything out. I'm back on a different computer, and it's working again. No idea why it wasn't working before. Thanks for your help anyway :) – John Dec 09 '14 at 20:47