Two Laptop Bag*
The moose likes Servlets and the fly likes Unable to run basic servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Unable to run basic servlet" Watch "Unable to run basic servlet" New topic
Author

Unable to run basic servlet

Prasanna Raman
Ranch Hand

Joined: Sep 05, 2010
Posts: 298
Hello,

I am not able to run the program below. It gives me the following error:

"HTTP Status 404 -

type Status report

message

descriptionThe requested resource () is not available."

The server is running at webpage.

I am using NetBeans 7.2.1. Here is my code:

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Have you followed the suggestions in the ServletsFaq?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

And why are you overidding service()?
Prasanna Raman
Ranch Hand

Joined: Sep 05, 2010
Posts: 298
It's just my first program, the code is from a book.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

OK, be aware that overriding service() is not recommended in general.

See the ServletsFaq for help in getting it running.
Prasanna Raman
Ranch Hand

Joined: Sep 05, 2010
Posts: 298
Thank you very much, got it to work!

Why is it not good to override the service() method?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Because the base class already provides means to figure out what the HTTP method of the request is, and to dispatch to doGet or doPost and so on. Why reinvent the wheel?

And you should not be treating requests to different HTTP methods in the same fashion. That's a really prevalent poor practice.
Prasanna Raman
Ranch Hand

Joined: Sep 05, 2010
Posts: 298
Thank you. Though it doesn't make complete sense to me at this time because I've just started learning servlets, I am sure I will come back to this at a later time. Is there a recommended Web site for learning Servlets?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

What book are you using? Make sure it shows you how to override doPost() and doGet().
Prasanna Raman
Ranch Hand

Joined: Sep 05, 2010
Posts: 298
OK, thank you very much.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to run basic servlet
 
Similar Threads
ConnectionNotFoundException
regarding unsupported post method
parameter from MIDlet cannot be displayed at servlet
Web Crawler - why it needs thread ??
Cant Run Simple Jersey REST Webservice Example