• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to run basic servlet

 
Prasanna Raman
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64621
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you followed the suggestions in the ServletsFaq?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64621
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And why are you overidding service()?
 
Prasanna Raman
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's just my first program, the code is from a book.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64621
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, be aware that overriding service() is not recommended in general.

See the ServletsFaq for help in getting it running.
 
Prasanna Raman
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much, got it to work!

Why is it not good to override the service() method?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64621
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64621
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What book are you using? Make sure it shows you how to override doPost() and doGet().
 
Prasanna Raman
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, thank you very much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic