JSP in /WEB-INF returns "HTTP Status 404 The requested resource is not available"

I created a JSP file.


<%@ page pageEncoding="UTF-8"%>
<!DOCTYPE html>
    <title>Insert title here</title>
    This is jsp program

I placed it here in the samplejsp project.

 `-- WebContent
      `-- WEB-INF
           `-- sample.jsp

I opened it on the following URL.


But it shows the following error in browser.


The requested resource (/sample.jsp) is not available.


404 simply means "Not Found".

Either the URL is wrong (note: case sensitive!), or the resource is not there where you think it is.

Just verify the URL and/or verify if the resource is there where you'd expect it to be. You placed sample.jsp in /WEB-INF folder. This way it is not publicly accessible without calling through a front controller servlet.

Put it outside /WEB-INF.

 `-- WebContent
      |-- WEB-INF
      `-- sample.jsp

If you want to keep it in /WEB-INF, then you need to create a front controller servlet which forwards to it in doGet() method as below.

request.getRequestDispatcher("/WEB-INF/sample.jsp").forward(request, response);

Finally "open" the JSP by just calling servlet's actual URL instead of JSP's fictive URL.

See also:

It's mostly related to your directory structure or packaging.
Can you please add your directory structure?

Similar to below -


Perhaps this should do it

<form action="sample.jsp" method=get>
      <input type =submit value="submit">

Edit - WEB-INF does not allow direct access to JSP.


 ? Tomcat started in Eclipse but unable to connect to http://localhost:8085/
 ? Why is @font-face throwing a 404 error on woff files?
 ? Routing for custom ASP.NET MVC 404 Error page
 ? How to check if a URL exists or returns 404 with Java?
 ? Best way to implement a 404 in ASP.NET
 ? How can I create an error 404 in PHP?
 ? How to get MVC action to return 404
 ? Image Get Requests with AngularJS
 ? What is the proper way to send an HTTP 404 response from an ASP.NET MVC action?
 ? ASP.NET Custom 404 Returning 200 OK Instead of 404 Not Found