Forums de discussion

Generating images

Dyrt Dancer, modifié il y a 14 années.

Generating images

Junior Member Publications: 49 Date d'inscription: 29/01/10 Publications récentes
Hi!
I need to create a JSP portlet, that shows dynamically generated image. I have a code to do this (generate and show an image) for HTTP Servlet, but I don't know, how to use this code for JSP portlet. Is it possible?
The code is following:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.awt.*;
import java.awt.image.*;
import javax.imageio.*;

public class ImageServlet extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
{
response.setContentType("image/jpeg");
try
{
BufferedImage bufferedImage = new BufferedImage(200, 200,
BufferedImage.TYPE_INT_RGB );
Graphics g = bufferedImage.getGraphics();
g.setColor(Color.blue);
g.fillOval(0, 0, 199,199);

Free graphic resources
g.dispose();
ImageIO.write(bufferedImage, "jpg", response.getOutputStream());
}
catch (Exception e){}
}
}
Dyrt Dancer, modifié il y a 13 années.

RE: Generating images

Junior Member Publications: 49 Date d'inscription: 29/01/10 Publications récentes
Up.
thumbnail
Ayushman Das, modifié il y a 9 années.

RE: Generating images

New Member Envoyer: 1 Date d'inscription: 20/06/14 Publications récentes
I am following approach and i have the same question too.Please help!!I am stucked
thumbnail
Olaf Kock, modifié il y a 9 années.

RE: Generating images

Liferay Legend Publications: 6403 Date d'inscription: 23/09/08 Publications récentes
That's what GenericPortlet.serveResource is for - or whatever it's been encapsulated in the framework of your choice.