The origin server did not find a current representation for the target resource or is not … error when running jsp page

♀尐吖头ヾ 提交于 2020-06-29 04:30:20

问题


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>

回答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 :

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.

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

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

localhost:8080/test/jquery.html

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




回答2:


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.



来源:https://stackoverflow.com/questions/56619409/the-origin-server-did-not-find-a-current-representation-for-the-target-resource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!