Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

requested resource not found error

 
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i was making my first web app and fall into this problem , the problem is when i click on a submit button on a html form (welcome page ) it directs me to a http 404 not found error (requested resource not found error)
my web.xml file


my actual servlet class

my welcome page

can any one help me please......???
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You haven't mapped your servlet to any URLs. You need a <servlet-mapping> tag in your web.xml.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Matthew Brown wrote:You haven't mapped your servlet to any URLs. You need a <servlet-mapping> tag in your web.xml.



still same problem
now what ?
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

naved momin wrote:still same problem
now what ?


And is your form posting to the URL that you've just mapped your servlet to?
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Matthew Brown wrote:

naved momin wrote:still same problem
now what ?


And is your form posting to the URL that you've just mapped your servlet to?


changed the form action to this

still the same 404 error ? now what else can we do ?
 
Marshal
Posts: 67273
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be prefixing the action url with the context path of the web app.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:You should be prefixing the action url with the context path of the web app.


you mean to say like this
 
Bear Bibeault
Marshal
Posts: 67273
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't believe no one has pointed this, but haven't you seen that your <servlet-class> in your DD ends with .Demo instead of .java

naved nomin wrote:

 
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
servlet class should never end with .java or any extension, just the fully qualified name of servlet should be given there..
 
Victor M. Pereira
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry, I forgot that part!
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when using your url pattern in the <form> tag, just omit the /
so, that your code will be,
<form action="demo" .........>
try and post your output
 
Bear Bibeault
Marshal
Posts: 67273
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

sridhar sivaraman wrote:when using your url pattern in the <form> tag, just omit the /
so, that your code will be,
<form action="demo" .........>
try and post your output


No. No. No. No. No. That's very bad advice.

Always start the action URL with the context path. Otherwise it's page-relative and fragile and will easily break with the smallest change in the web application.

Follow best practices. They exists because they've been proven to work.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!