This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Servlets and the fly likes ImageObserver in servlets 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 "ImageObserver in servlets" Watch "ImageObserver in servlets" New topic

ImageObserver in servlets

Bob Moranski
Ranch Hand

Joined: Nov 22, 2000
Posts: 177
Hi, I have a question on ImageObserver in servlets. Why is it sometimes we need to create the ImageObserver on the class level and other times as a local variable of doGet()? What is the difference?
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12678
The obvious difference is that a local variable should only exist for the duration of the request-response cycle, whereas an instance variable will hang around for the life of the servlet object.
I'm really curious as to what you are doing that needs an ImageObserver at all? When I need to load an Image into a servlet I use a MediaTracker.

Java Resources at
Bob Moranski
Ranch Hand

Joined: Nov 22, 2000
Posts: 177
Hi, don't you have to have an ImageObserver as the parameter to a MediaTracker object?
MediaTracker mt = new MediaTracker(frame); ? frame is an ImageObserver?
I agree. Here's the link:
subject: ImageObserver in servlets
Similar Threads
creating BufferedImage object in a servlet
Help me in calculating image data
drawImage(Image, int, int, ImageObserver)
Use of ImageObserver ?
drawImage to Panel