Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why should be public?

 
Ganesan Ramakrishnan
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have the doubt in servlet class declaration, is there any specific reason for declaring servlet class as public??

Regards
Ganesan
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why shouldn't it be public?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15359
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The servlet container should be able to access your servlet class. If it wouldn't be public, the servlet container wouldn't be able to create instances of the servlet.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic