• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

error 404 requested resource not found in Eclipse

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys, I have a simple hello.jsp file in my "HelloWorld" project.
But when i am running it i am getting ERROR 404.

But a simple .java file(from another project) is running properly ....


Here's my hello.jsp file :

"<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Hello World</title>
</head>
<body>
Hello World!!
</body>
</html>"




here's my web.xml file :

"<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>HelloWorld</display-name>
<welcome-file-list>
<welcome-file>hello.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>"


Configurations are done properly ...

Please help out.....
i am newbie to Programming world....
 
Ranch Hand
Posts: 439
Hibernate Eclipse IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Sagar Dafle ,

Can you please specify what URL are you typing in the browser to access the JSP ? The URL should be of the format http://localhost:8080/<project_context>/<web_page_dir>/hello.jsp

The project_context is most probably the name of your project and the web_page_dir is the directory where you are making the JSP files. If the JSP are made inside the WebContent ( or webapp ) folder directly then just omit this entry and the URL will be http://localhost:8080/<project_context>/hello.jsp .

Also do specify the project hierarchy that you have made. It will help us determine what is your project structure and how to access the JSP from browser .
 
Ranch Hand
Posts: 63
Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you share your application directory structure?
 
Sagar Dafle
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanxx for the concern and quick reply ASIF and NIRAJ

i have attached my project hierarchy and the error page ....... with both http://localhost:8080/HelloWorld/hello.jsp and http://localhost:8080/HelloWorld/WEB-INF/hello.jsp urls, i am getting the same error....



error-404.JPG
[Thumbnail for error-404.JPG]
PROJECT DIRECTORY
 
Saif Asif
Ranch Hand
Posts: 439
Hibernate Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found your mistake . You are directly attempting to access a JSP resources inside the WEB-INF directory. You can not do that. Anything inside the WEB-INF is protected from direct access. So to access your JSP page , just simply move it outside the WEB-INF folder to the WebContent . WebContent is your root folder and any JSP resource can be directly accessed from here. Once you have moved out the JSP , just hit the URL http://localhost:8080/HelloWorld/hello.jsp and it will work fine.
 
Sagar Dafle
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
:') :'( :'( :')


THANKS A TONNNNNNN SAIF !!!
now i am able to run it successfully !

i have been struggling with such a silly mistake from yesterday !!

GOD BLESS you saif and niraj .......
Keep helping people
 
Saif Asif
Ranch Hand
Posts: 439
Hibernate Eclipse IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your welcome :-)
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Saif,
I am facing the same problem as above and my program is almost similar. Also my helloWorld.jsp file is inside Web-content and not web-inf. Still i am getting the error that resource not found. All my tomcat connections are fine because it shows tomcat welcome page when i go to localhost. I am new to this and have been struggling to this for last 3-4 hours. I would appreciate any help.

PS: Attached are the screenshots.

Thanks,
Nishant.
snap3.PNG
[Thumbnail for snap3.PNG]
snap2.PNG
[Thumbnail for snap2.PNG]
snap.PNG
[Thumbnail for snap.PNG]
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

nishant dahiya wrote:Hi Saif,
I am facing the same problem as above and my program is almost similar. Also my helloWorld.jsp file is inside Web-content and not web-inf. Still i am getting the error that resource not found. All my tomcat connections are fine because it shows tomcat welcome page when i go to localhost. I am new to this and have been struggling to this for last 3-4 hours. I would appreciate any help.

PS: Attached are the screenshots.

Thanks,
Nishant.



Right click on the Tomat server and click "clean". Then right click one more time and click "clean Tomcat work Directory".
Then run the web app.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Sir, your post was very helpful.
 
If you have a bad day in October, have a slice of banana cream pie. And this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic