Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

doPost/doGet public or protected?

 
Joel Hutters
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I have a question about the doPost and doGet methods in the HttpServlet class. They are defined as protected in the API so what shall I use when create my servlets? I have seen that some people, books use public and some use protected. Since I actually extend the HttpServlet class when I create my own shouldn't it actually be preferable to use protected?

This is driving me nutz so please explain me the difference (I know the difference about the scopes) but not the difference when implementing it in my servlets.

Nice to be here
[ September 07, 2006: Message edited by: Joel Hutters ]
 
Paul Clapham
Sheriff
Posts: 21945
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could explain the difference between the public and protected scopes, but you say you know that already. And you don't want to know the difference when you implement it in your servlets? Then I can't tell what you do want to know. But fortunately it makes no difference at all in practice.
 
Joel Hutters
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe I'm not that sure about it then, so please explain if possible.
 
Paul Clapham
Sheriff
Posts: 21945
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Making it protected means you can't do something like this:But that would be a really strange thing for somebody to do in a web application. Basically you wouldn't ever do it anyway. That's why I say it makes no difference in practice.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!