Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

requested resource not found error

 
naved momin
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......???
 
Matthew Brown
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 ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65110
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
Author and ninkuma
Marshal
Pie
Posts: 65110
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Victor M. Pereira
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:

 
Prasad Krishnegowda
Ranch Hand
Posts: 670
4
Eclipse IDE Java Spring
  • 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!
 
sridhar sivaraman
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
Author and ninkuma
Marshal
Pie
Posts: 65110
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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