aspose file tools*
The moose likes Servlets and the fly likes using graphics in servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "using graphics in servlets" Watch "using graphics in servlets" New topic
Author

using graphics in servlets

mateen dar
Greenhorn

Joined: Dec 27, 2004
Posts: 26
hi i am ceating a web application that must open a picture and then draw on it. i have done it in desktop applications, but now want to use in a servlet. can i use the graphics2d library from within a servlet and how would u translate the following code,


try
{
MediaTracker tracker = new MediaTracker(this);
tracker.addImage(img, 0);
tracker.waitForID(0);
}


the img is a fle read from the hadrd drive. and the this referebce is the reference for a jframe class. how can i use the above code in a servlet. thanks.
mateen dar
Greenhorn

Joined: Dec 27, 2004
Posts: 26
i think i did not make my self clear in the above post. i want toread a image file, into a buffered image. how could i do that.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
I just went through exactly this problem - my previous graphics work was in Applets and used MediaTracker but it turns out the situation has greatly improved since then. Now I am using the ImageIO class - which does not start a separate Thread.

where theImage is a BufferedImage reference.

And to draw on that image, you do a typical


To cope with various image formats, the JAI package found here seems to be where the future support is.
Bill
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Depending on the OS you're using, you may need to run your app server with the "headless" JVM option.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using graphics in servlets