aspose file tools*
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
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: 335
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: 61628
    
  67

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: 61628
    
  67

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

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

Joined: Jan 10, 2002
Posts: 61628
    
  67

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: 335
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: 61628
    
  67

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: 335
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: 61628
    
  67

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: 335
OK, thank you very much.
 
 
subject: Unable to run basic servlet