Jsp Sign Up is the first jsp the user encounter and it takes the data from the user and move them to another jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Shapes Calculator</title>
</head>
<body style="text-align:center">
<h1 style="text-align:center">Shapes Calculator</h1>
<form action="Sign_Up Check.jsp" method="post">
<br><br><br><br>
First Name: <input style="height:27px;font-size:13pt;" type="text" name="Fname" size="30" > <br> <br> <br>
Last Name: <input style="height:27px;font-size:13pt;" type="text" name="Lname" size="30" > <br> <br> <br>
E-mail: <input style="height:27px;font-size:13pt;" type="text" name="Email" size="30" > <br> <br> <br>
Username: <input style="height:27px;font-size:13pt;" type="text" name="Username" size="30" > <br> <br> <br>
Password: <input style="height:27px;font-size:13pt;" type="password" name="Password" size="30">
<br> <br> <br> <br> <br>
<input style="height:25px;font-size:12pt;" type="submit" value="Sign Up !">
</form>
</body>
</html>
the second jsp is the one responsible for creating objects of the classes we made and putting the data we got from the previous jsp to the classes (! this is the jsp where 404 happens when reaching it !)
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:useBean id="data" class="Classes.DB" scope="application" >
</jsp:useBean>
<jsp:useBean id="user" class="Classes.User" scope="session" >
<jsp:setProperty property="*" name="user" />
</jsp:useBean>
<jsp:forward page="Sign_Up_Servlet"></jsp:forward>
and finally this is the Servlet that we are supposed to go to but somehow manage to never reach it
package Classes;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletContext;
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;
import Classes.*;
/**
*
* @author LEGION45
*/
@WebServlet(urlPatterns = {"/Sign_Up"})
public class Sign_Up_Servlet extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
}
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
ServletContext context=request.getServletContext();
DB database=(DB)context.getAttribute("data");
HttpSession session=request.getSession();
User user=(User)session.getAttribute("user");
int check=database.insertUser(user);
if(check > 0){
request.getRequestDispatcher("New_User.jsp").forward(request, response);
}
else{
session.removeAttribute("user");
request.getRequestDispatcher("Sign-Up.jsp").forward(request, response);
}
}
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
And this is the error
404 means not found, this is on the webserver itself. Double check that you're connecting to the correct url in the java application. Also for future reference the http codes can be useful when debugging, just google "http " and things will come up explaining what it means