0

Hello

Im trying to generate a image from a servlet and display it with browser.

Lets say I want to do something like this:

protected void doPost(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, java.io.IOException {  
                  BufferedImage bufferedImage = new BufferedImage(620, 420, BufferedImage.TYPE_INT_RGB);
		Graphics2D g2d = bufferedImage.createGraphics();
		g2d.setColor(Color.black);
		g2d.fillRect(0, 0, 620,420);  
		g2d.setColor(Color.yellow);
		bufferedImage.getGraphics();
}

This simply generates a box with a box rect. Ignore the yellow.....

Now obviously I have to get the response as I call the servlet again and display the image (as it physically isnt stored anywhere)

How can I do this? Or somewhere I can start at least.....

Thanks.

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by riahc3
0

Hello

Im trying to generate a image from a servlet and display it with browser.

Lets say I want to do something like this:

protected void doPost(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, java.io.IOException {  
                  BufferedImage bufferedImage = new BufferedImage(620, 420, BufferedImage.TYPE_INT_RGB);
		Graphics2D g2d = bufferedImage.createGraphics();
		g2d.setColor(Color.black);
		g2d.fillRect(0, 0, 620,420);  
		g2d.setColor(Color.yellow);
		bufferedImage.getGraphics();
}

This simply generates a box with a box rect. Ignore the yellow.....

Now obviously I have to get the response as I call the servlet again and display the image (as it physically isnt stored anywhere)

How can I do this? Or somewhere I can start at least.....

Thanks.

check here maybe:http://www.exampledepot.com/egs/javax.servlet/GetImage.html

0

check here maybe:http://www.exampledepot.com/egs/java.../GetImage.html

Wouldnt I have to check for something like a postback? This way when the servlet is loaded, I can load the image (which doesnt exist as it is generated by the servlet) and display it.

Although I would like to save the image on the current directory and load it from there.

0

I dont think this is too difficult as Ive done it in courses Ive done and it took tops a hour. I right now dont remember how to do it so if someone could help out....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.