• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stock up on JSP 404 error. JSP could not be located.

 
victor chiong
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
victor chiong wrote:http://localhost:8080/Beer-v3/WEB-INF/jsp/result.jsp

You cannot access a resource under WEB-INF via URL.

RequestDispatcher view = request.getRequestDispatcher(" result.jsp ");

What's with the spaces?
 
victor chiong
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Need the leading slash, and no space!
 
victor chiong
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic