开发者

JSTL error (HTTP Status 404 - /JSTL/home) [duplicate]

开发者 https://www.devze.com 2023-02-08 23:26 出处:网络
This question already has answers here: JSP in /WEB-INF returns "HTT开发者_运维技巧P Status 404 The requested resource is not available"
This question already has answers here: JSP in /WEB-INF returns "HTT开发者_运维技巧P Status 404 The requested resource is not available" (3 answers) Closed 6 years ago.

I am trying to use redirect tag for directing index page to the home page residing in my web project's JSP folder. The hierarchy of my project is as under:

WEB-INF
     jsp
        home.jsp
index.jsp

I am using both the libraries jstl 1.2 and standard.jar Following is the code of my index.jsp

<%@ taglib prefix="core" uri="/tags/c" %>

<core:redirect url="/home"></core:redirect>

When i run the project i recieve the following error;

HTTP Status 404 - /JSTL/home
type Status report
message /JSTL/home
description The requested resource (/JSTL/home) is not available.


Files in /WEB-INF are not public accessible (it's not available when you enter their address in browser address bar). The <jsp:include> and any servlets using RequestDispatcher are the only which can access them.

So if you have a controller servlet which is mapped on /* and dispatches the request as follows

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

then your <c:redirect> will work. But if you don't have such a controller, then you should use <jsp:include> or move the home.jsp into public webcontent (there where your index.jsp also is) and redirect to home.jsp instead.


Unrelated to the problem, the way you declared the JSTL taglib doesn't give me a strong feeling you're doing things the right way or reading the proper tutorials. I suggest you to take a look in our JSTL tag wiki.


You need to redirect to "/home.jsp", not just "/home".

0

精彩评论

暂无评论...
验证码 换一张
取 消