This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Calling doGet() method from init() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Calling doGet() method from init() method" Watch "Calling doGet() method from init() method" New topic
Author

Calling doGet() method from init() method

Sreenivasa Rao Pitchuka
Greenhorn

Joined: Dec 24, 2002
Posts: 18
Hi,
In my application, I need to start a Servlet at server startup.For that I'm using a load-on-startup param.From this (i.e from init())I need to execute another task through doGet() method. Is it possible.
Please inform ASAP.
Thanks and regards,
Sreenivas
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

You cannot call doGet from init because you do not have request and response object to pass one, unless you create an instance of those yourselves.
Why dont you call the task method directly.


Groovy
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

The way you do this is to make the task separate from both the init() and doGet() methods, and you can then call it from either one.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling doGet() method from init() method
 
Similar Threads
Getting HttpSession from the init method
Cached Collection?
How to call service() from init()
is other method also synchronized
service() method overriden