Search code examples
javanetbeansglassfish

Java Web Application Return Error HTTP 404 Not Found


I am learning java with netbeans . I build web application for insert, update and delete operation. but when i run the application its always returns error 404 not found .

Here is the HTML Code that i want to run .

<!DOCTYPE html>
<!--
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.
-->
<html>
    <head>
        <title>Add New</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <h1>Add New</h1>
        <div style="width: 900px; margin-left: auto; margin-right: auto">
            <form action="JSP/ManagerAddNew.jsp" method="post">
                Title:<br>
                <input type="text" name="title" style="width: 200px"><br>
                Description:<br>
                <input type="text" name="description" style="width: 200px"><br>
                Detail:<br>
                <textarea name="detail" style="width: 400px; height: 200px"></textarea><br>
                Category: 
                <select name="category">
                    <option value="World">World</option>
                    <option value="Tech">Tech</option>
                    <option value="Sport">Sport</option>
                </select><br>
                Image:<br>
                <input type="text" name="image" style="width: 200px"><br>
                <input type="submit" value="Submit">
            </form>
            <!--Complete Interface Addnew.-->
        </div>

    </body>
</html>

Here is the screen shot of the error message . enter image description here

Here is my project structure .

enter image description here

Here is the screen of the server and the application has been deployed . enter image description here


Solution

  • i don't know about GlassFish Server,but tomcat. A JSP file under WEB-INF folder can't be visit by URL directly,you can visit it like this:

    request.getRequestDispatcher(“/WEB-INF/xxx.jsp”).forward(request,response);
    

    I'm not sure this way can solve the question under GlassFish,hope it can help you.