my dog learned polymorphism*
The moose likes Servlets and the fly likes requested resource not found error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "requested resource not found error" Watch "requested resource not found error" New topic
Author

requested resource not found error

naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 688

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......???


The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4338
    
    7

You haven't mapped your servlet to any URLs. You need a <servlet-mapping> tag in your web.xml.
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 688

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

Joined: Apr 06, 2010
Posts: 4338
    
    7

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

Joined: Jul 03, 2011
Posts: 688

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

Joined: Jan 10, 2002
Posts: 60741
    
  65

You should be prefixing the action url with the context path of the web app.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 688

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

Joined: Jan 10, 2002
Posts: 60741
    
  65

Victor M. Pereira
Ranch Hand

Joined: Mar 02, 2012
Posts: 50
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:



regards,
Victor M. Pereira
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 507

servlet class should never end with .java or any extension, just the fully qualified name of servlet should be given there..


Regards, Prasad
SCJP 5 (93%)
Victor M. Pereira
Ranch Hand

Joined: Mar 02, 2012
Posts: 50
sorry, I forgot that part!
sridhar sivaraman
Greenhorn

Joined: Mar 02, 2012
Posts: 13
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

Joined: Jan 10, 2002
Posts: 60741
    
  65

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: requested resource not found error
 
Similar Threads
getting error when deploying web app in weblogic 10.0
Log4j will not write to log file.
Problem with session timeout
Problem with simple HTML - Servlet login
how to call JSP from Servlet