Generating Dynamic Images (more than one)

Hello everyone, I'm trying to create a jsp page that show's a group of images dynamically selected by the user. I want to be able to draw separate images separated by some text. I can get the jsp to draw one image but it then ignores everything after that. Here's my code. Any help would be greatly appreciated.
<%@page contentType="text/html"%>
<%@page import="com.sun.image.codec.jpeg.*, java.awt.*, java.awt.image.*, java.io.*" %>
<html>
<head><title>JSP Page</title></head>
<body>
<%
ServletOutputStream os = response.getOutputStream();
BufferedImage image1 = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d1 = image1.createGraphics();
g2d1.setColor(Color.red);
g2d1.fillOval(10, 10, 80, 80);
BufferedImage image2 = new BufferedImage(100, 200, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d2 = image2.createGraphics();
g2d2.setColor(Color.blue);
g2d2.fillOval(10, 10, 80, 180);
JPEGImageEncoder encoder1 = JPEGCodec.createJPEGEncoder(os);
//JPEGImageEncoder encoder2 = JPEGCodec.createJPEGEncoder(os);
encoder1.encode(image1);
os.flush();
response.setContentType("text/html");
%>
hello?
<%
encoder1.encode(image2);
os.flush();
%>
</body>
</html>
I also tried:
<%@page contentType="text/html"%>
<%@page import="com.sun.image.codec.jpeg.*, java.awt.*, java.awt.image.*, java.io.*" %>
<html>
<head><title>JSP Page</title></head>
<body>
<%
ServletOutputStream os = response.getOutputStream();
BufferedImage image1 = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d1 = image1.createGraphics();
g2d1.setColor(Color.red);
g2d1.fillOval(10, 10, 80, 80);
BufferedImage image2 = new BufferedImage(100, 200, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d2 = image2.createGraphics();
g2d2.setColor(Color.blue);
g2d2.fillOval(10, 10, 80, 180);
JPEGImageEncoder encoder1 = JPEGCodec.createJPEGEncoder(os);
//JPEGImageEncoder encoder2 = JPEGCodec.createJPEGEncoder(os);
encoder1.encode(image1);
encoder1.encode(image2);
os.flush();
%>
</body>
</html>
Thanks in advance for any help.
EB

Hi eb,
The solution is very easy
Here is a servlet(ImageTester) which creates an image on the fly ....
It can be acessed at say url http://localhost:8080/servlet/ImageTester
wirte another HTML file test.html as under
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<img src="http://89.193.88.15:8080/servlet/ImageTester">
Text Item
<img src="http://89.193.88.15:8080/servlet/ImageTester">
</BODY>
</HTML>
/* source for ImageTester.java */
import java.awt.*;
import java.awt.image.*;
import com.sun.image.codec.jpeg.*;
import java.util.*;
import java.io.*;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
import java.awt.image.BufferedImage;
import javax.servlet.*;
import javax.servlet.http.*;
public class ImageTester extends HttpServlet
public void init()
throws ServletException
public void doGet(HttpServletRequest request, HttpServletResponse httpservletresponse)
throws IOException, ServletException {
// httpservletresponse.setContentType("image/" + s);
// httpservletresponse.setContentType("image/jpg");
// javax.servlet.ServletOutputStream servletoutputstream = httpservletresponse.getOutputStream();
// httpservletresponse.setHeader("Pragma", "no-cache");
// httpservletresponse.setHeader("Cache-Control", "no-cache");
// httpservletresponse.setDateHeader("Expires", 0L);
// Create image
int width=200, height=200;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
// Get drawing context
Graphics g = image.getGraphics();
// Fill background
g.setColor(Color.white);
g.fillRect(0, 0, width, height);
// Create random polygon
Polygon poly = new Polygon();
Random random = new Random();
for (int i=0; i < 5; i++) {
poly.addPoint(random.nextInt(width),
random.nextInt(height));
// Fill polygon
g.setColor(Color.cyan);
g.fillPolygon(poly);
// Dispose context
g.dispose();
// Send image to browser
httpservletresponse.setContentType("image/jpg");
OutputStream outputStream = new BufferedOutputStream(httpservletresponse.getOutputStream(), 1024);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(outputStream);
encoder.encode(image);
outputStream.close();
public void doPost(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
throws ServletException
try
doGet(httpservletrequest, httpservletresponse);
catch(Exception exception)
exception.printStackTrace();
Cheers!!!!!
ezaz khan

Similar Messages

  • Cannot image more than one computer simulteneously

    When I try to image more than one computer simulteneously, the computer
    freezes. I have Zenworks for desktops Ver 6.5 and netware 6.5.
    Please help!
    Thanks,
    Mike

    Jared,
    The workstation freezes. The imaging process freezes as soon as I start
    imaging another workstation.
    Thanks,
    Mike
    > mmbugi,
    >
    > > When I try to image more than one computer simultaneously, the
    computer
    > > freezes. I have Zenworks for desktops Ver 6.5 and netware 6.5.
    >
    > The server freezes or the workstation? Multicast or just simple image
    pull.
    >
    > --
    > Jared Jennings
    > Data Technique, Inc.
    > Novell Support Forums Sysop
    > http://wiki.novell.com
    >

  • Generating excel with more than one tab

    Hi,
    I would like to ask if anyone of you know how to generate excel file from Oracle Reports with more than one tab? Is it possible? If yes, can you provide me some references on how to do it. Thanks in advance.

    Hi,
    Do this:
    1. Create an Excel file, put some dummy data in 2 or more worksheets. Save as HTM. This will create one main HTM file, and some sub-files under a folder. One HTM sub-file will be created per worksheet. In addition, one XML sub-file (called filelist.xml) and some other sub-files will be created. (you have already done this)
    2. Open one of the HTM sub-files in reports builder, and follow the steps shown in the Excel Demo on OTN to insert data in this file at appropriate place, and save as JSP.
    http://otn.oracle.com/products/reports/htdocs/getstart/demonstrations/excel/index.html
    3. You can repeat this step for all worksheets. So finally you will get one JSP file per worksheet.
    5. Now open the main file in reports builder, and add the Excel contentType element at the top
         <%@ page contentType="application/vnd.ms-excel; charset=windows-1252" %>
    6. In this file, search for the following tag
         <x:WorksheetSource HRef="./filename_files/sheet001.htm"/>
    Note that instead of filename_files you will have your own file name
    Change this tag as following:
         <x:WorksheetSource HRef="./filename_files/sheet001.jsp?userid=scott/tiger@myDb"/>
    Note that in userid, you must provide your own DB connect string
    7. Additionally, change ALL references to sheet001.htm in this file to sheet001.jsp
    Do steps 6 and 7 for sheet002.htm, sheet003.htm, and so on (if needed).
    8. Open filelist.xml (you will find this file inside the folder that contains sub-files). Here, too, change all references to JSP instead of HTM
    9. Now place the main JSP file as well as the folder containing all sub-files inside your J2EE deployment folder. Run the main JSP file. This will run the associated JSP files (the worksheets).
    This will do the trick.
    If you are worried about placing the USERID information inside your JSP code, then you can use CGICMD.DAT file, and place the userid there.
    Navneet.

  • Email Not generated from VF06 - more than one invoice created same BP

    Customer is creating invoice in VF01, they need a email output (medium 5) along with SAP Script attached . I coded the logic in subroutine Entry of the print program. Email is getting generated successfully .
    But it production the customer is creating invoices by VF06, infact VF06 is a batch Job to create Invoices.
    For eg: using VF06 if they run batch job, 2 or more invoices are getting created for the same business partner, only for the first invoice email is getting generated, but it only sends one email related to the first invoice generated. Though the outputs are getting processed for other invoices we are not getting any emails.
    We are sending email by using the FM SO_DOCUMENT_SEND_API1, if i use commit = 'X', and run Vf06, its sending an error notification stating error doing commit.
    Also I checked all the sort options in VF06, Still it wont work.
    Can any body  please help me how to proceed. Your valuable help is appreciated <removed by moderator>.
    Regards
    Ravi
    Edited by: Thomas Zloch on Jul 2, 2011 7:24 PM

    Standard program is modified by customer.

  • Dynamically populating more than one field using xml data binding

    Hi All,<br /><br />I have the following code that works fine to dynaically populate a<br />second drop-down list2 from a choice in drop-down list1 using xml data<br />biding.<br /><br />var tempString = "xfa.record." + this.boundItem(xfa.event.newText);<br />var oItems = xfa.resolveNode(tempString);<br />var nItemsLength = oItems.nodes.length;<br /><br />myinfo.page1.state.clearItems();<br />myinfo.page1.state.rawValue = null;<br /><br />for (var nItemCount = 0; nItemCount < nItemsLength; nItemCount++)<br />{<br />myinfo.page1.state.addItem(oItems.nodes.item(nItemCount).value);<br />}<br /><br />Here is my xml file<br /><br /><?xml version="1.0" encoding="UTF-8"?><br /><myinfo><br /><country/><br /><countries><br /><item uiname="United States" token="US"/><br /><item uiname="South Africa" token="SA"/><br /><item uiname="Australia" token="AU"/><br /></countries><br /><state/><br /><AU><br /><item>Australian Capital Territory</item><br /><item>New South Wales</item><br /><item>Northern Territory</item><br /><item>Queensland</item><br /><item>South Australia</item><br /><item>Tasmania</item><br /><item>Victoria</item><br /><item>Western Australia</item><br /></AU><br /><US><br /><item>California</item><br /><item>New York</item><br /><item>Texas</item><br /><item>Michigan</item><br /><item>North Carolina</item><br /><item>South Carolina</item><br /></US><br /><SA><br /><item>Eastern Cape</item><br /><item>Free State</item><br /><item>Gauteng</item><br /><item>KwaZulu-Natal</item><br /><item>Limpopo</item><br /><item>Mpumalanga</item><br /><item>Northern Cape</item><br /><item>North-West</item><br /><item>Western Cape</item><br /></SA><br /></myinfo><br /><br />I have two questions:<br /><br />1) I want to be able to structure my xml in a way that I can populate<br />a third drop-down list3 from a choice in list2. I need to know how to<br />to include the different capital cities of the states in my xml data<br />so that they can get populated in list3 from a selection in list2;<br /><br />2) And be able to script the third list3 to get dynamically populated<br />from a choice in list2.<br /><br />Thanks in advance for your help.

    I would like to ask someone for help.
    I have an XML file a result of the XSLT transformation. A schema was created based on this XML and this schema is bound to a form as a data source.  When I preview my form using a Preview tab with transformed XML as a Data File in LiveCycle Designer 8.1, I can see only the first form data across 3 Text fields on the form. The rest of the forms are not getting displayed. What am I doing wrong?
    Here is the part of the XML file Im trying to display on the form:
        FORM 1
        FORM 1 DESCRIPTION
        $5000
        FORM 2
        FORM 2 DESCRIPTION
        $7000
        FORM 3
        FORM 3 DESCRIPTION
        $4000
    Part of the schema that was created based on the XML file from above:
    Thank you.

  • How to find all generated profiles (with more than one nomenclature)

    Hello all,
    I have an Solution Manager 4.0 system and I want to find out:
    a. all sap profiles created via SU02 (not generated profiles)
    b. all generated profiles
    b. all generated profiles with user assignment
    Initially I extracted values from tables UST10C and UST10S for single and comp. profile information. For profile assignment, I searched UST04. But then I realized that generated profiles don't follow a standard nomenclature. Some start with T-54, some with T-56, then T-AA, T-MW [now there some T_MW profiles created via SU02 ]
    Can anyone help me here please?
    Thanks and regards,
    Sundar.

    Hi Sundar,
    please check table USR10.
    The interesting field for you is USR10-Typ.
    Field value meanings:
    C    Composite Profile 
    G    Generated Profile 
    S    Single profile   
    b.rgds, Bernhard

  • Generating duplicates using more than one condition

    dear experts I have the following sample data below
    create table tbl_one
      p_id number(30),
      c_id number(30),
      location_a varchar2(300),
      flag varchar2(1)
    insert into tbl_one
      (p_id, c_id, location_a, flag)
    values
      (1, 112, 'ref_1', '1');
    insert into tbl_one
      (p_id, c_id, location_a, flag)
    values
      (1, 113, 'ref_1', '1');
    insert into tbl_one
      (p_id, c_id, location_a, flag)
    values
      (1, 114, 'ref_2', '1');
    insert into tbl_one
      (p_id, c_id, location_a, flag)
    values
      (2, 115, 'ref_3', '1');
    insert into tbl_one
      (p_id, c_id, location_a, flag)
    values
      (2, 116, 'ref_3', '1');
    insert into tbl_one
      (p_id, c_id, location_a, flag)
    values
      (2, 117, 'ref_4', '1');this is the output I desire below
    PID    C_ID    LOCATION_A     FLAG
    1        112     ref_1                 1
    1        113     ref_1                 1
    2        115     ref_3                 1
    2        116     ref_3                 1basically the output is obtained for all cases where the location_A and flag are duplicated in the same pid
    I need help with the query. All help is appreciated. Thank you

    select p_id, c_id, location_a, flag from
    select p_id, c_id, location_a, flag, count('Dracula') over (partition by p_id, location_a, flag) cnt
    from tbl_one
    where cnt > 1
    order by p_id, c_id
    P_ID     C_ID     LOCATION_A     FLAG
    1     112     ref_1     1
    1     113     ref_1     1
    2     115     ref_3     1
    2     116     ref_3     1

  • Problem with Assigning more than one value to GROUP dynamically

    Hi,
    I have a problem with assigning more than one value to GROUP varible dynamically.
    I am able to assign only one value dynamically through Initialization block
    I have even tried with the ROW-WISE initialization blocks..
    using this query..
    SELECT 'GROUP', G.GROUP_NAME
    FROM GROUP_MAP G
    WHERE G.USER_NAME = ':USER'
    if GROUP_1, GROUP_2 are two groups to be associated,
    through this, i'm getting " GROUP_1;GROUP_2 " into GROUP variable ( seen from Narative view )
    And the properties and securities of this Groups are not inherited.
    Please let me know if there is any other way to Populate the GROUP variable dynamically with more than one value.
    Thank you.,

    Hi,
    i finally got in this way..
    i had created a function which takes USER_NAME as input and returns a string that contains the GROUP names with semicolon delimeted..
    Though it is same as that of ROW-WISE initialization,
    the properties of those groups are also being inherited..
    Now, i can assign more than one groups and its properties to a user dynamically.

  • Error - Can't open more than one image in CS3

    My Photoshop CS3 was working fine until all of a sudden it no longer lets me open more than one image at a time without crashing. Anyone else have this problem? How do I fix it?

    Hi,
    There may be two issues you have to check:
    1) The " scratch disk" feature in photoshop(usually gets full). Go to preferences - performance. Also check how much RAM PS is using.
    2) Printer Communication: sometimes Photoshop is unable to communicate with the default printer(may be unstable drivers, out of date etc). Network computers also make some issues
    If you want to read more about this follow this link:
    http://www.fluther.com/disc/22453/photoshop-cs3-not-opening-more-than-one-image-at-a-time/
    They talk about the issues I mentioned here. Let me know if you found this information useful.
    Vicente Tulliano

  • In Keynote, how do I put more than one image on a single slide?

    I would like to put 2, 3, or 4 “pictures” on a single slide, and program them with transitions so that they could pop-on or dissolve one at a time.  Is it possible to put more than one image placeholder on a slide?

    Yes. Just copy-paste the placeholder that the theme has, multiple times.

  • Can one add more than one photo layer to a draw image?

    I cannot seem to find a way to add more than one photo or photo layer to a Draw image, but the Draw page on Adobe seems to imply multiple photos can be added. How might I accomplish this? Thanks for your time.

    Unfortunately, Draw is currently limited to one photo layer, and only one photo within that layer.
    Hope that helps,
    Frank
    Draw Engineering

  • How to show more than one image on my screen at same time?

    I recently upgraded to PS-CS4 from CS3 and notice that I can only view one image on my screen. Is there a way to view more than one image on the screen at the same time? I cannot seem to find a way to change this feature.
    Thanks, Richie

    John Joslin wrote:
    In addition, if you don't like the tabs, select Float All in Windows from the Arrange Documents drop-down in the Menu bar up top.
    Or keep pressing the F key.
    The drop-down bar also has a conveneint way of fitting multiple images on the screen. See the illustration below:

  • How do I view more than one image at the same time in CS6?

    How do I view more than one image at the same time in CS6?

    Hi there
    If you go to Window > Arrange you can choose from several view options. Below I have selected Two-Up Horizontal since I have two images, but you can select other options if you have more than one image.

  • Is there a way to reset more than one image at a time?

    I have a folder with 1100 images taken on four different cameras. I have a new default setting for one of the cameras that I would like to apply to most but not all of the images in this folder. I could remove the offending images and reimport, I could filter by serial number and sync a preset. It would be easier, however, if could just select the images I want and hit the reset tool and reset all the images selected. But it only seems to reset the dominant image. Any way to get the reset button to work on more than one image at a time?
    Gordon

    do it in Grid not Filmstrip or Develop.
    Don
    Don Ricklin, MacBook 2Ghz Duo 2 Core running 10.5.1 & Win XP, Pentax *ist D See LR Links list at http://donricklin.blogspot.com for related sites.

  • Can I have more than one album art Image displayed on ipod per song?

    Can someone help?
    My issue is that in itunes I can add more than one image (album art) to an individual song. While it's playing, in the display album art (bottom left corner) I can flick through all the images a particular song contains. I got exicted and came to the assumption that not only can I display album art (covers) but also single art (covers) for songs that got release from an album on my ipod. However when I downloaded all the tracks on to my ipod it only displays album art and not single art (covers) for released songs. Is there a way I can have both album and single art displayed on my ipod for a song? I spent hours finding these single art covers on the internet!
    30Gig ipod (Black)   Windows XP  
    30Gig ipod (Black)   Windows XP  

    On the iPod you can only display one picture attached to that song. The one that gets assigned to the song is the first picture on the list in iTunes.

Maybe you are looking for