0

I am trying to run this code in my Eclipse JSP dynamic web page. But on running it in the Tomcat Server Version 9.0, I am getting an error 404 message. Error Message-The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. I was trying to include a header page in my other jsp page in this code.

So far I have tried switching the location of the server via server properties. I have also checked the Use Tomcat installation checkbox in Server Locations. Still, I am getting this error.

  <!DOCTYPE html>
  <html>
  <head>
  <title>Insert title here</title>
  </head>
  <body>
  <jsp:forward page="http://localhost:8080/HelloJSP/HeaderPage.jsp" /> 
  </body>
  </html>
vasudha Jha
  • 1
  • 1
  • 1
  • Is your HeaderPage.jsp under WEB-INF folder? Also, maybe check your web project settings in your Eclipse. – Jin Lee Jun 16 '19 at 14:43
  • Where is HeaderPage.jsp in your project? Is your project deployed as HelloJSP? Does that URL load correctly on its own? What does the server log show for that request? – nitind Jun 16 '19 at 15:48
  • @JinLee Yes, It is under WEB-INF Foder. Could you please refer which setting should I focus on in web project settings in Eclipse? – vasudha Jha Jun 16 '19 at 17:28
  • @nitind It's under the same project file under WEB-INF. My Project's Name is not HelloJSP but the url on which my HeaderPage was working correctly is as mentioned in the code's Include jsp tag. The server is loading the Header Page correctly. But it's showing the above error when I try to run the above code for this other JSP file on tomcat. – vasudha Jha Jun 16 '19 at 17:33

2 Answers2

1

If the page is under WEB-INF folder, an 404 error message might appear. I had the similar problem.

I put the pages under the WebContent folder instead. In Eclipse, the location of files may look confusing. Sometimes right click the file and look at their properties for paths. Just like below :

enter image description here

As you can see, even though pages look like they are under WEB-INF, they are under WebContent. Then, you won't see 404. And you can put the url to see your page in your browser.

If this doesn't help, then check your Web Project Settings.

enter image description here

Right-click your project, go to Properties, and find Web Project Settings.

Can you see my Context root "/" ? If I want to run my jquery.html page, I just type

localhost:8080/jquery.html

enter image description here

If you change your context root to "test", then you type :

localhost:8080/test/jquery.html

enter image description here

enter image description here

Don't forget to clean your Tomcat after changing your context root. Otherwise, it won't apply changes.

enter image description here

Community
  • 1
  • 1
Jin Lee
  • 3,194
  • 12
  • 46
  • 86
0

Thank You for your help :) Actually, this problem was solved once I removed all the server from eclipse and switched it off. Then I readded the sever once again and it started working. Still not able to find the reason this error was caused but it was fixed by using the above method.

vasudha Jha
  • 1
  • 1
  • 1