Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why service method doesn't run?

 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


when i run this it gives

ctor
init
doGet

as result.Why service method doesn't run?
 
Paul Clapham
Sheriff
Pie
Posts: 20771
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See my answer on your crosspost.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64632
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've copied Paul's answer below and removed the other post.
Paul Clapham wrote:Some other method named service() with different parameters will have run.

 
Praneeth Thiruveedhula
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
in your program that service method is just like normal method.that method does't contain any parameters and does't throws any exception. so that is just like normal method. bydefault that method won't executes,and you have to call explacitly.

if you wrote the service method as follows then it may executes bydefault.

public void service(ServletRequest request,ServletResponse response)throws ServletException
{
System.out.println("javamirchi");
}

 
Ashwin Bangar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the service method you have written is an ordinary method and wont be called by the servlet container.
it is as if you have given a return type to constructor and hoping it to execute when you follow an object creation process.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic