1

I created a folder named jsp in WEB-INF & putting all the .jsp files in this folder. I changed the web.xml

It's giving HTTP Status 404 /JasperPjt/jsp/Login.jsp Not found.

Please help me out.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Saroj Kumar
  • 21
  • 1
  • 3

5 Answers5

5

The main purpose of putting JSP files in WEB-INF directory is that it will be accessible from the server only, not from client end.(Client will not be able to know the exact URL of file).

If you try to call that file(Files in WEB-INF), server will return HTTP 404.

Just call servlet and then you can call that JSP file like :

request.getRequestDispatcher("/WEB-INF/TargetJspFile.jsp").forward(request, response);
Charles Caldwell
  • 16,649
  • 4
  • 40
  • 47
Prakash13
  • 91
  • 1
  • 9
0

You will not be able to access files inside WEB-INF by default. Generally all the jsps and other UI contents should be organized under your application root directory and outside WEB-INF. Probably you can have MyApp/pages which cotains your jsps and MyApp/WEB-INF separately.

Yasin
  • 1,906
  • 1
  • 21
  • 37
0

You can't access .jps files under WEB-INF folder you can access .jsp under Webcontent folder and its the root folder for all UI and other UI related files.

If your seperating them then you need get the conetxt path from that you can access.

the actual structure is:

HelloWorld
   |
   ---->src
   |
   ---->wecontent
           |
           ----->WEB-INF
           |
           ----->index.jsp

if your seperating

HelloWorld
   |
   ---->src
   |
   ---->wecontent
           |
           ----->WEB-INF
           |
           ----->jsps
                  |
                  |---> login.jsp
                  |---> welcome.jsp

like this now you need to get like this in jsp

<% String path = request.getContextPath(); %>

<a href="<%= path %>/jps/welcome.jsp">Wecome</a>
Adi Inbar
  • 12,097
  • 13
  • 56
  • 69
  • To place text in code blocks, indent by four spaces, or select the text and click the `{}` button in the toolbar. – Adi Inbar Jul 24 '14 at 16:19
0

You could create a public accessible JSP e.g. as yourproject/web/login.jsp and link your private JSP yourproject/web/WEB-INF/pages/somesnippet.jsp with this code:

<%@ include file="/WEB-INF/pages/somesnippet.jsp" %>
S. Doe
  • 685
  • 1
  • 6
  • 25
-1
  1. You cannot directly access files from WEB-INF Folder. You need to either redirect or forward request to it.

  2. If you are redirecting or forwarding and then getting this error then,

    /JasperPjt/WEB-INF/jsp/Login.jsp

    or I think

    /WEB-INF/jsp/Login.jsp or WEB-INF/jsp/Login.jsp

This should also work.

gprathour
  • 14,813
  • 5
  • 66
  • 90