| Author |
Stock up on JSP 404 error. JSP could not be located.
|
victor chiong
Ranch Hand
Joined: Apr 04, 2012
Posts: 73
|
|
Hi Guys,
I could not see the error on this problem... Why it could not locate my jsp? I am using NET Beans IDE and TOMCAT 7.012
http://localhost:8080/Beer-v3/WEB-INF/jsp/result.jsp
HTTP Status 404 - /Beer-v3/ result.jsp
type Status report
message /Beer-v3/ result.jsp
description The requested resource (/Beer-v3/ result.jsp ) is not available.
Apache Tomcat/7.0.12
here is the servlet:
My JSP
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56185
|
|
victor chiong wrote:http://localhost:8080/Beer-v3/WEB-INF/jsp/result.jsp
You cannot access a resource under WEB-INF via URL.
What's with the spaces?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
victor chiong
Ranch Hand
Joined: Apr 04, 2012
Posts: 73
|
|
Hi,
So where should i place it?
Index.jsp is found on WEB-INF/JSP so I place my result.jsp there. So where should i place it? The spaces is what i am doing to see if my jsp will be found or not. spaces or no spaces, it could not found my result jsp.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56185
|
|
victor chiong wrote:So where should i place it?
Having it under WEB-INF is fine as long as you are forwarding to it from a servlet. But you cannot access it directly without the servlet -- which is usually exactly what you want.
The spaces is what i am doing to see if my jsp will be found or not. spaces or no spaces, it could not found my result jsp.
No spaces. But you need to include the path to the JSP. Otherwise how would its location be known?
|
 |
victor chiong
Ranch Hand
Joined: Apr 04, 2012
Posts: 73
|
|
Hi,
Something like I am super new to this... sorry for the question...
RequestDispatcher view = request.getRequestDispatcher("WEB-INF/JSP/result.jsp "); ?
Thanks,
Vic
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56185
|
|
|
Need the leading slash, and no space!
|
 |
victor chiong
Ranch Hand
Joined: Apr 04, 2012
Posts: 73
|
|
Hi,
Still the same....
HTTP Status 404 - /Beer-v3/WEB-INF/JSP/result.jsp
type Status report
message /Beer-v3/WEB-INF/JSP/result.jsp
description The requested resource (/Beer-v3/WEB-INF/JSP/result.jsp) is not available.
Apache Tomcat/7.0.12
Inside of the doPost Method..
String c = request.getParameter("color");
BeerExpert be = new BeerExpert();
List result = be.getBrands(c);
request.setAttribute("styles", result);
RequestDispatcher view = request.getRequestDispatcher("/WEB-INF/JSP/result.jsp");
view.forward(request, response);
|
 |
victor chiong
Ranch Hand
Joined: Apr 04, 2012
Posts: 73
|
|
Hi,
I had solve the problem...
I transfered result.jsp to the main folder from Web pages/WEB-INF/JSP to Web pages/result.jsp. the problem with that is that I think it is better to place it in JSP folder? But how would you do it?
RequestDispatcher view = request.getRequestDispatcher("/Web Pages/WEB-INF/jsp/result.jsp");
RequestDispatcher view = request.getRequestDispatcher("/WEB-INF/jsp/result.jsp");
code above does not work....
regards,
Vic
|
 |
 |
|
|
subject: Stock up on JSP 404 error. JSP could not be located.
|
|
|