How to return many images to browser?

hi all
im having a servlet which will create an array of images!
and i would like to send it to the browser via html, how can i do this?
if im confusing, im trying to create a servlet which creates charts as images dynamically, and it should send the images to client browser as HTML.
thanks and regards
vijay

hi
thank u so much!
that gave me the starting point!
hope i can crack rest of the code!
[i modified my design like one servlet creates multiple charts and put it in session object. another servlet like what u said, responds to image tag requests!  thanks again]
thanks and regards
vijay

Similar Messages

  • Return an Image from a subclass to a graphics class

    Hello
    I'm wondering how to return an Image generated by one class to a class which works as a graphics class. The graphics class is run from a main class. Let me make up a schedule:
    Image-generator return Image -> graphics class paint
    I have tried just making an Image and using the getGraphics to connect a graphics object to it, but it doesn't seem to work.
    Thanks in advance

    Okay, here are the pieces of code we use. (Comments are in Swedish but they are barely relevant, and explain merely basically what is happening in the program)
    The applet is compilable, but there is a nullpointerexception in Elefanträknaren, at getGraphics(). Believe me, I have tried finding the solution to this already.
    Spelet (main method)
    import java.applet.*;
    import java.awt.*;
    public class Spelet extends Applet
         /*Elefanträknaren testerna;*/
         Ritaren ritarN;
         Graphics g;
         public void init()
              /*testerna = new Elefanträknaren();*/
              ritarN = new Ritaren(g, getSize().width, getSize().height);
              setLayout(new GridLayout(1, 1));
              add(ritarN);
         public void start()
              ritarN.startaTråd();
         public void stop()
              ritarN.stoppaTråd();
         public void update(Graphics g)
              paint(g);
    }Ritaren (graphics object)
    import java.awt.*;
    public class Ritaren extends Panel implements Runnable
         Elefanträknaren e;
         Graphics g;
         int bredd, höjd;
         //Trådobjekt
         Thread tråd;
         public Ritaren(Graphics g, int bredd, int höjd)
              this.bredd = bredd;
              this.höjd = höjd;
              e = new Elefanträknaren(bredd, höjd);
         public void startaTråd()
              if( tråd == null )
                   tråd = new Thread(this); //Skapa tråden
                   tråd.start(); //Kör igång
                   e.startaTråd();
         public void stoppaTråd()
              if( tråd != null )
                   tråd.interrupt();
                   tråd = null;
         public void paint(Graphics g)
              g.drawImage(e.getSpökbilden(), 0, 0, this);
         public void update(Graphics g)
              paint(g);
         public void run()
              while( tråd != null )
                   repaint();
                   try
                        Thread.sleep(33);
                   catch(Exception e){}
    }Elefanträknaren (class generating the Image)
    import java.awt.*;
    import java.util.*;
    import java.awt.image.BufferedImage;
    import javax.swing.ImageIcon;
    public class Elefanträknaren extends Panel implements Runnable
         //Vektorn som innehåller alla Elefant-klasser
         private Vector elefanterna;
         //Ritobjektet för den dubbelbuffrade bilden
         private Graphics gx;
         //Bildobjektet för dubbelbuffringen
         private Image spökbilden;
         private int bredd, höjd;
         //Trådvariabeln
         private Thread tråd;
         //Rörelsen uppdateras 30 ggr/s. RÄKNARE håller koll på när en elefant ska läggas till (efter 30 st 30-delar = 1 ggr/s)
         int RÄKNARE = 30;
         int ÄNDRING = RÄKNARE;
         //DELAY betecknar delayen mellan två bilder/frames. 33 ms delay = 30 FPS
         int DELAY = 33;
         //Konstruktor
         public Elefanträknaren(int bredd, int höjd)
              elefanterna = new Vector();
              this.bredd = bredd;
              this.höjd = höjd;
         //Kör igång tråden/ge elefanterna liv
         public void startaTråd()
              if( tråd == null )
                   tråd = new Thread(this); //Skapa tråden
                   tråd.start(); //Kör igång
                   //Dubbelbuffringen initieras - detta måste ligga i startaTråd()
                   //spökbilden = new BufferedImage(bredd, höjd, BufferedImage.TYPE_INT_ARGB);
                   spökbilden = createImage(bredd, höjd);
                   gx = spökbilden.getGraphics();
         //Stoppa tråden/döda elefanterna
         public void stoppaTråd()
              if( tråd != null )
                   tråd.interrupt();
                   tråd = null;
         //Lägg till en elefant i vektorn
         private void läggTillElefant(Elefant e)
              elefanterna.add(e); //Lägg till en Elefant som objekt i vektorn
              Elefant temp = (Elefant)     elefanterna.get(elefanterna.size()-1);
              temp.startaTråd(); //Starta Elefantens tråd - ge Elefanten liv
         //Sätter ihop bilden som ska sickas till Ritaren
         public void uppdaterarN()
              //Rensa skärmen från den förra bilden
              gx.fillRect(0, 0, bredd, höjd);
              for( int i = 0; i < elefanterna.size(); i++ )
                   Elefant temp = (Elefant) elefanterna.get(i);
                   gx.drawImage(temp.getBild(), temp.getX(), temp.getY(), null);
         public Image getSpökbilden()
              return spökbilden;
         //Tråd-loopen
         public void run()
              while( tråd != null )
                   RÄKNARE++;
                   if( RÄKNARE >= ÄNDRING )
                        läggTillElefant(new Elefant(11, 50, 900));
                        RÄKNARE = 0;
                   uppdaterarN();
                   //repaint();
                   try
                        Thread.sleep(DELAY);
                   catch(Exception e){}
    }Elefant (a class which Elefanträknaren turns into an Image:
    import java.awt.*;
    import java.util.*;
    import javax.swing.ImageIcon;
    public class Elefant extends Panel implements Runnable
         private int x, y; //Elefantens koordinater
         private int hälsa; //Elefantens hälsa
         private int RÖRELSESTEG = 10;//Antal pixlar elefanten ska röra sig i sidled
         private int DELAY;
         //Animation
         private Vector bilderna = new Vector();
         private Vector bilderna2 = new Vector();
         private int fas; //Delen av animationen som ska visas
         private boolean framåt;
         //Tråddelen
         private Thread tråd;
         public Elefant(int x, int y, int hastighet)
              this.x = x;
              this.y = y;
              DELAY = 1000 - hastighet;
              hälsa = 100;
              framåt = true;
              fas = 0; //Nollställ fasen
              //Få fram bildernas namn
              for( int i = 0; i <= 5; i++ )
                   Image temp = new ImageIcon("Z:\\Projektet\\gamal\\Projektet\\Mappen\\mediat\\png\\jumbo" + i + ".png").getImage();
                   bilderna.add(temp);
                   Image temp2 = new ImageIcon("Z:\\Projektet\\gamal\\Projektet\\Mappen\\mediat\\png\\jumbo" + i + "r.png").getImage();
                   bilderna2.add(temp2);
         //get-variabler
         public int getX() { return x; }
         public int getY() { return y; }
         //Kör igång tråden/ge elefanten liv
         public void startaTråd()
              if( tråd == null )
                   tråd = new Thread(this); //Skapa tråden
                   tråd.start(); //Kör igång
         //Rör elefanten i sidled
         private void rörelse()
              //Animering
              if( fas < 5 ) fas++;
              else     fas = 0;
              //Flytta ner elefanten när den når en av spelets kanter
              if( x >= 800 || x <= 10 ) y += 85;
              //Kontrollera riktning
              if( x >= 800 ) framåt = false;
              else if( x <= 10 ) framåt = true;
              //Positionering
              if( framåt ) x += RÖRELSESTEG;
              else x -= RÖRELSESTEG;
         //Hämtar den aktuella bilden, och returnerar den
         public Image getBild()
              Image temp;
              if( framåt ) temp = (Image) bilderna.get(fas);
              else temp = (Image) bilderna2.get(fas);
              return temp;
         /* Tråd-hantering */
         //Stoppa tråden/döda elefanten
         public void stoppaTråd()
              if( tråd != null )
                   tråd.interrupt();
                   tråd = null;
         //Körs när elefanten är vid liv
         public void run()
              while( tråd != null )
                   rörelse();
                   try
                        Thread.sleep(DELAY);
                   catch(Exception e){}
    }

  • How do I save images?

    its probably very simple and ill feel stupid reading the answer but how do i save images while browsing on my phone

    dmcritchie that won't work on Firefox mobile.
    If you can open the image directly such as http://upload.wikimedia.org/wikipedia/en/7/73/UpHellyAa7%28AnneBurgess%2930Jan1973.jpg if you long click on the image you will get a context menu with save image as an option. If the image is part of a page I don't think you will be able to save the image.

  • When browsing a new library that I created, the browser shows dotted lines around grey rectangles, no images. When I double click on a rectangle the image appears. How do I get images to appear in the browser rectangles?

    When browsing a new library that I created and exported onto an external hard drive, the browser shows dotted lines around grey rectangles, no images. When I double click on a rectangle, the image appears, but all the other rectangles remain empty - no image. How do I get images to appear in the browser rectangles? I am viewing this on a second computer (an older intel duo iMac), not the one I created the library on (a MacBook Pro). Both computers have Aperture 3.2.4 installed. When I return the external to the MacBook, all images appear in browser rectangles. What's happening on the iMac?

    You may have a problem with the permissions on your external volume. Probably you are not the owner of your library on the second mac.
    If you have not already done so, set the "Ignore Ownership on this Volume" flag on your external volume. To do this, select the volume in the Finder and use the Finder command "File > Get Info" (or ⌘I).
    In the "Get Info" panel disclose the "Sharing & Permissions" brick, open the padlock, and enable the "Ignore Ownership on this Volume" flag. You will have to authentificate as administrator to do this.
    Then run the "Aperture Library First Aid Tools" on this library and repair the permissions. To launch the "First Aid Tools" hold down the ⌥⌘-key combination while you double click your Aperture Library. Select "Repair Permissions" and run the repair; then repeat with "Repair Database". Do this on the omputer where you created the library and where you can see the thumbnails.
    Then check, if you now are able to read the library properly on your iMac.
    Regards
    Léonie

  • How many images per sec can I get from ImageIO.read(url) ??????

    Hello,
    In my program I read images from a url...I'm wondering how many images I can get with ImageIO.read(url) per second..
    Hereby is the code that I'm using:
    import java.awt.*; //Contains all of the classes for creating user interfaces and for painting graphics and images
    import java.awt.event.*;//Provides interfaces and classes for dealing with different types of events fired by AWT components
    import java.awt.image.*;//Provides classes for creating and modifying images
    import java.io.*;//Provides for system input and output through data streams, serialization and the file system
    import java.net.URL;
    import javax.imageio.*;//The main package of the Java Image I/O API.
    import javax.swing.*;//Provides a set of "lightweight" (all-Java language) components that, to the maximum degree possible, work the same on all platforms.
    import java.text.*;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    public class getPic extends Component{
    private BufferedImage img;
        static int n=0;
        private URL url;
        private DateFormat dateFormat;
        private Date date;
        private String s;
        private String str1= ".jpeg";
        private String str2="C:\\Users\\";
        private String str3;
        private String str4;
          public getPic() {
         try {
                  url = new URL("http://"); //a url that gives a real-time image
                  img = ImageIO.read(url);
                } catch (IOException e) {
               System.err.println("Unable to read file");
    public void savePic(){
    try{
    n++;
    str3=str2.concat(Integer.toString(n-1));
                        str4=str3.concat(str1);
                        ImageIO.write(img, "jpeg" , new File(str4));
                    } catch(IOException e) {
                      System.err.println("Unable to output results");
    @Override
        public Dimension getPreferredSize() {
            if (img == null) {
               return new Dimension(100,100);
            } else {
               return new Dimension(img.getWidth(), img.getHeight());
        @Override
          public void paint(Graphics g) {  //http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Paint.html
            g.drawImage(img, 10, 10, null);//http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Graphics.html
        public static void main(String[] args) throws IOException {
           JFrame f = new JFrame(" Image without processing!!");
           f.addWindowListener(new WindowAdapter(){//http://java.sun.com/j2se/1.4.2/docs/api/java/awt/event/WindowListener.html
                @Override
                    public void windowClosing(WindowEvent e) {
                        System.exit(0);
        int i=0;
        for( ; ; ){
            i++;
            getPic pi = new getPic();
            pi.savePic();
            f.add(pi);
            f.pack();  //Causes this Window to be sized to fit the preferred size and layouts of its subcomponents.
            f.setVisible(true);
         try
            Thread.sleep(1000);
            }catch (InterruptedException ie)
            System.out.println(ie.getMessage());
    }Thank you in advance for your answers
    Joan

    Finally I solved my problem(getting as many images as possible from a url infinitely) using the above code:
    import java.net.*;
    import java.io.*;
    public class UserApplication {
        private static int n=0;
        String url;
      public void UserApplication(){
        public static void main(String[] args) throws Exception {
            UserApplication app= new UserApplication();
            for(;;){
            app.urlStr();
        private void urlStr(){
            try{
                url= "http://mplamplampla/frame.php/";
                HttpURLConnection con=(HttpURLConnection) ((new URL(url).openConnection()));
                BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream("C:\\Users\\mpla\\Desktop\\" + n + ".jpeg"));
                con.setDoInput(true);
                con.setDoOutput(false);
                con.setRequestMethod("GET");
                BufferedInputStream in = new BufferedInputStream(con.getInputStream());
                int bt = 0;
                byte[] buffer = new byte[4096];
                while ((bt = in.read(buffer, 0, 4096)) > -1) {
                  out.write(buffer, 0, bt);
                in.close();
                out.close();
                System.out.println("Image " + n + " saved");
                n++;
                } catch (Exception e) {e.printStackTrace();}
    }

  • How to return and display an image created by a Struts 2 action object?

    Hi all, I'm Andrea and this is my first post on SDN.
    I'm developing a web based application using Struts 2 and I've got a problem with images management. It follows a brief description:
    Using a form in a jsp page it is possible to make a call to the execute() method implemented in a class, extending ActionSupport.
    At the end of the method there's the following instruction:
    BufferedImage image = generateChart();
    My problem is that I need to return this image to the client, so that his browser could display it.
    Unfortunately I don't know exactly how to proceed.
    I've seen it's possible to define result type for Struts 2 actions through xml config file, but I don't what I need to write into che action class.
    Could you help me with this topic?

    Ok I found the answer to your problem. If you download the tutorial they have the code there it's in one folder. I hope this helps.
    http://java.sun.com/docs/books/tutorial/

  • How to return a html repsonse after form guide rendering in browser?

    How to return a html repsonse after form guide rendering in browser indicating that server has recieved transmission and request is submitted succesfuly?
    I am rendering the form guide in browser using guide invoke service and when i submit the data in browser to server through guide , it is displaying some random number in browser?
    i need to display a resposne that request is submitted successfully?

    how could i define a variable with "html data" ?
    Create a variable of type document and then a service to read the html from where ever it's located. If you put it in LiveCycle, you can use the ReadRessource service. If it's on the file system, you can use the Read Document. If it's in the database, you can use the JDBC service.
    Also, one more doubt where should i use this variable in my process to get the same?
    You want the response once you've submitted the data, so the html is really the result of calling the process that's processing the data. So I would create an output variable of type document on that process.
    Right now it displays a random number in the browser because your submit process is long lived. When a process is long lived (asynchronous), you invoke it and then you get an identifier back. It's kind of a fire and forget. You can use that identifier to check the status of the long lived process, since long lived processes can take hours, days to complete. You don't want your browser to wait that long, hence the identifier.
    However if you change the process to be short lived (synchronous), the browser will wait for the result of the process, which really means the output variables for that process. If your output variable contains html, it'll display html.
    So the key is make you submit process short lived and populate the output variables appropriately.
    Jasmin

  • How to switch off 'crop' edit in many images at once?

    I know how to lift and stamp to apply edits to several selected images at once. However, if I have cropped many images within a project in different ways, then want to switch off the crop on all of them, is there a way? Without laboriously going through one-by-one and un-checking the 'crop' box?
    Likewise is it possible to apply auto-exposure to many images (batch process)? When stamping, it applies the exact same exposure change from the lifted version, but different images require different exposure compensations of course.

    1 - yes, on one image leave the crop box checked and click the circular arrow (reset) ... this has the crop enabled but no crop ... then L&S that adjustment to all the ones you want, you just reset the crop on all of them ...
    2 - no ... with the auto adjustment it creates an adjustment ... when you L&S that adjustment, that is what you get, that specific adjustment ... you are one of hundreds that want that and ask for it here ... use the feedback menu option to send feedback to dev team ... or use http://www.apple.com/feedback/aperture.html

  • How can I return to the previous browsing page in the App store?

    How can I return to the previous browsing page in the App store?

    Thanks for your reply but problem not solved. If I have reached page 5 for example, I can not go back to the previous page 4. Instead it goes back to page 1 when I use the back track arrows, gestures or the back or forward commands!! The girl at my local Apple dealer says that it can't be done. This should be a very basic browsing function in the App Store. I know other people have the same problem.

  • How to upload the image and diplay the image in the browser using jsp

    How to upload the image and diplay the image in the browser using jsp
    thanks
    shan

    i'll suggest looking for sample code or tutorial with a relevant query in google, which as far more time than us to answer this type of reccurent question

  • I did a presentation with many images and animations, now I need to change only the images without modify the related animations. How can I do it?

    I did a presentation with many images and animations, now I need to change only the images without modify the related animations. How can I do it?
    I use Keynote 09

    Select the image you want to change and go to Format Menu>Advanced>Define as Media Placeholder (or command, option, control i).

  • Memory usage Adobe Photoshop Elements 9 - How many images are too many?

    My wife and I are having a discussion about the memory allocation of Adobe PSE 9.
    We run both of our profiles logged in on a 27" iMac top end from May, 2010, with 12 GB of RAM.
    She had a number of pictures open (let's say 20 - 25) that she was working on editing.  Trying to shut the program down or work within it, the spinning wheel of death made a cameo appearance and brought the system to a crawl.
    I ran Activity Monitor and it said that she had 746 MB of memory free out of 7.39 GB active and 11.27 GB used.  With each image I closed, I gained an additional 5 - 7 MB of free memory.
    Once I force quit PSE 9, that number jumped to nearly 2.5 GB free.
    For those with experience using PSE 9, can you give me an indication:
    How many images do you have open that you're working with at the same time?
    For those people with more Mac OS X experience, would having 750 MB free out of 12 GB reduce the computer to a crawl?
    Thanks in advance.

    As a general rule of thumb (some will disagree with me) if your machine has about 500MB of Free RAM or less this will slow down the computer significantly. Also as a general rule you can never have too much RAM. One nice thing about your machine is it can be upgraded up to as much as 32GB of RAM however 8GB chips are EXTREMELY expensive right now and currently only OWC sells a kit. You can upgrade to 16GB for a lot less, whether you need it or not no one here can say for sure. I would continue to keep an eye on Activity Monitor and keep my first sentence in the back of your mind.
    Roger

  • I imported a different catalog. It brought all images in but not in their folders and multiple times on many images. How do I undo?

    I imported a different catalog. It brought in all images but not in their folders and multiple times on many images. How do I undo?

    Restore your catalog from a backup of your catalog which was made before you did this.

  • OT but relevant - Just how many images do you have?

    These are my own opinions and I'm just interested in other peoples thoughts......
    I frequently see posts on this and other forums where people are stating that they have tens of thounds of images. I think the highest I saw recently was over 40,000. (My basic assumption is that these are not Pros)
    Its got me wondering about whether the Digital Camera age has also resulted in a culture of Quantity versus Quality that we see in so many other aspects of life.
    I've been interested in Digital Photography for 10 years and I'm still not over the 5000 mark. Maybe this is because I grew up on film and couldn't afford to waste materials and time. Over 95% of what I shoot I consider worth keeping and processing.
    I'm not saying there's anything wrong with having as many images as people want but consider the amount of overhead these bring. Megabytes of disk storage, hours spent Reviewing, Organising and Processing. Back to my perhaps contentious statement - how many of these are worth keeping or taking in the first place?
    As they say on Exam Papers - Discuss? :-)
    Colin

    I read a statement from Ansel Adams that went something like, "Twelve significant photos in a year is plenty." I suppose if you are striving for masterpieces that would be true. But personally, I like the economy of digital photography.
    Last summer a bunch of us from my family took a trip to Alaska. Between all of us we had five digital cameras. And they were all used extensively on the trip. At one point we had an opportunity to take a flight over Mount McKinley. All the batteries were dead except for those in one camera, and we only had one card available because we hadn't taken the time to download images for a while. Luckily, the one camera captured some beautiful shots from the flight. They weren't all perfect, and probably none of them would be considered masterpieces. But at least we have a memory of the trip. When we got home and consolidated all of our pictures we 10 CDs full of images. From all of those images we chose about 60 to create a small album to be printed by mypublisher.com. But we have all gone back to those disks to get other pictures for other purposes. We have been glad that we had them.
    What boggles my mind is when I read comments that someone has several external hard drives containing their digital images. After I have gone through a bunch of pictures and chosen the best ones and discarded the bad ones, and then have printed the few that I want prints of, I find that I seldom go back and look at them again. So I am archiving on DVD and then deleting them from my hard drives. I know, there is a controversy over the longevity of such a practice. But I plan on routinely making new copies of each DVD and an effort to preserve the images. So far, I have not had any problems.
    I have been doing a lot of experimental photography lately. I have been playing around with HDR (High Dynamic Range) which requires several images that are the same except taken at different exposures. And that can fill up a card in a hurry. With experimental photography I think one has to evaluate which, if any, of these images will ever be used again, and then have the discipline to erase all the ones that will never again be needed or looked at. There are very few images that any of us have that are worth agonizing about if they are lost. A picture is just that, a picture. If you have some that you absolutely cannot do without, come up with a storage system that works for you. But keeping every photograph taken is really a waste of disk space, in my opinion.

  • How many images can iPhoto 2.01 hold?

    How many images can iPhoto 2.01 hold? What's the maximum.
    And why does iPhoto occassionally crash when dragging folders of images into the Album list area?
    thanks,
    Hairfarmer

    I have 70,000 RAW images arranged in directories by year/day.  The only thing slow about it is during catalog backup. When first starting LR it takes a couple of minutes to enumerate the dates with photo counts, but that occurs in the background.  I detect no database related slowness while editing or performing random accesses and searches.  I have seen no difference in the above after having upgraded to V4.
    The only slowness that I find annoying has nothing to do with the database.  It is after a certain number of spot removals of varying sizes. The larger and/or more varied the spot size tends to accelerate this.  At some point it starts disk thrashing and becomes impossible to work with (I have to back up to a history step when it was running OK, which can take several minutes).  When this occurs the task manager shows a high rate of page faults, meaning it is swapping out stuff to disk (even though I have plenty of unused ram).  This suggests a problem with the compiler, but that is just an wild educated guess.

Maybe you are looking for

  • How to get a reference for custom controller

    Hi All,      I am working with the custom controller but i dont know how to call the functionality of custom controller into a view controller.For accessing component controller functionality we have a attribute wd_comp_controller in view controller.

  • HT4623 I can't update my iOS on my iPhone 4!

    everytime I try to update, it never initializes because it always ends up with an error. And everytime I try to update it with iTunes on my PC, it hangs and I have to start all over again. BUT I NEVER GET A CHANCE TO UPDATE IT BECAUSE OF AN ERROR.

  • How to get ipad 2 to recognize printer

    I can get to a print dialog but no printer is available.  I have an HP Pro P1102w.  It should work.

  • WiFi Profile keeps getting disabled

    I'm always having issues where the WiFi profile gets disabled. My school has a number of access points all with the same connection info and so I should be able to connect onto all the different access points seemlessly, however, it seems to get disa

  • X58 Pro-E USB3 and Asus U3S6...supported?

    All, I took a risk and got an Asus U3S6 card at Amazon for $25.  Yea, I know it says you need an Asus board!  I wanted to add more SATA ports and have full-bandwidth USB3. It's really not a big deal anymore as I found a 90-degree SATA cable and can n