aspose file tools*
The moose likes Servlets and the fly likes Why service method doesn't run? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Why service method doesn Watch "Why service method doesn New topic
Author

Why service method doesn't run?

anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237


when i run this it gives

ctor
init
doGet

as result.Why service method doesn't run?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18114
    
    8

See my answer on your crosspost.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Praneeth Thiruveedhula
Greenhorn

Joined: Oct 20, 2009
Posts: 19
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

Joined: Jul 02, 2009
Posts: 10
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.


SCJP 5
Now Moving for SCWCD and then for OCA & OCP
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why service method doesn't run?
 
Similar Threads
Servlet Destroy method
when the destroy() methid caled
service() method overriden
Servlet init method behavior
When destroy method is called?