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/

Similar Messages

  • How to download and display an image.

    Hi,
        I am using BSP application  to upload an image to table. It is successfully uploaded.
        It is stored as string format.
        Now,   How can I retrieve and view it in the browser ?
        Please answer for my question ..
    Regards,
    Rajesh
    Moderator Message: You will get replies if you ask the question in the right forum
    Edited by: kishan P on Sep 16, 2010 10:39 AM

    hello,
    check out this link:
    http://www.corej2me.com/DeveloperResources/sourcecode/networking/downloadPng/index.shtml
    hope it helps you out :)
    cheers :)
    cleoppatra

  • How to place an image in database and how to retrieve and display it in the front end

    how to place an image in database and how to retrieve and display it in the front end
    and to place an image in database and retrieve the image from database using xml
    please,help me out.

    Create a table with a Long RAW Datatype column for storing the Image Column Data.
    Create the form based on the table , which by defaults the column with LONG RAW atatype to a Image Item.
    You can use Forms Built in function READ_IMAGE_FILE to read a Image file stored on the file system in to the image item.
    A save on the form saves the image in the Image item in the long raw column.

  • How to  upload and display image using bsp application

    hi
    I  just wants to know that
    1- how to  upload image from BSP page with attachment into sap server .?
    2-how to display image in to BSP page(webpage).
    thanks

    Hello Gupta Prashant,
    Just to upload and display an image, import image in MIME repository. Not only still images but also flash files can also be uploaded in the MIME repository. Once you import the image in it, use normal html code for image call;
    <img src = "file.jpg/gif" width=  height=>
    Besides it, if your requirement is to store the image in the database and fetch it based on specified field-name, then you have to go for BLOBs i.e Binary Large Object, using this you can also store images, videos, pdfs, applications in the database.
    MBLOB - Medium BLOBs store videos and pdfs,
    LBLOB  - Large BLOBs store movie files and applications.
    You have got 2 ways to use it; some databases store BLOB objects into themselves and some store the path of the BLOB object maintained on the FTP server.
    You can also implement it in ABAP;
    read the following link and practice the tutorial;
    [ Use of MIME Types|http://help.sap.com/saphelp_45b/helpdata/en/f1/b4a6c4df3911d18e080000e8a48612/content.htm]
    also check this
    [TYPES - LOB HANDLE|http://help.sap.com/abapdocu/en/ABAPTYPES_LOB_HANDLE.htm]
    And looking at your question, in order to upload an image, you can make use of FILEUPLOAD tag provided by HTMLB.
    Step 1: FILEUPLOAD provides a browse button to choose desired image file.
    Step 2: Store that image in database using BLOBs.
    Step 3: Retrieve the image using normal select query and display it on the screen.
    Hope it helps you,
    Zahack

  • How to Snap/Grab Image from 1394 camera and display the Image in CWIMAQVIEWER in VC++ ?

    Hi,
    I have :  -  IMAQ1394 2.0.1
                  -  NI Vision 7.1
    In VB, I can Snap/Grab Image from 1394 camera and display the Image in CWIMAQVIEWER :
        Dim Image0 As New CWIMAQImage
        imaq1394SnapCW(sid0,Image0)
        CWIMAQViewer1.Attach Image0
    Now,How can I do this in VC++6.0?
        I tried:
                  C_CWIMAQImage m_imgViewer1;
                  m_imgViewer1 = m_CWIMAQVision1.CreateCWIMAQImage();
                  m_CWIMAQViewer1.Attach(m_imgViewer1);
                  imaq1394SnapCW(Sid,m_imgViewer1);  <--there is no "imaq1394SnapCW "function in VC++,why?
        Please help me!
        Thank you!

    For people looking back at these old posts regarding
    CWIMAQViewer - it was not made to be used in the C environments and is made
    for VB.
    Refer to the following locations for displaying images in C
    environments:
    Start»All Programs»National Instruments»Vision»Documentation
    Start»All
    Programs»National Instruments»Vision»Text Based Examples
    Make
    sure that you look at the examples and documentation that is in
    reference to the C environments not the VB environments
    Vince M
    Applications Engineer

  • How can I simultaneously acquire and display an image on the front panel using a PCI-1408

    I have to acquire and display an image directely in the front panel of a *.vi using a PCI-1408. i have to know all informmations about this image because I want to create a calibration system.

    Hi Paola,
    if you own IMAQ Vision you can just have a look at the examples that comes with your board or you can look at: http://zone.ni.com/devzone/explprog.nsf/6c163603265406328625682a006ed37d/2abaefe05789961686256866007c0d22?OpenDocument.
    Without IMAQ Vision look at:
    http://zone.ni.com/devzone/explprog.nsf/6c163603265406328625682a006ed37d/22474456534202b086256aff005fc4f3
    (or search at ni.com for "IMAQ Display without IMAQ Vison)
    Please mail me if you need further help,
    Michael

  • How to acces and display datas storaged in cache for a SUP 2.0 workflow?

    HI to all.
    I have an application with a item menu which obtains data thought a online request. the result is shown is a listview.
    My problem is when my BlackBerry has no conection ( offline scenario). When I select the menu item, I obtain an error.
    How to acces and display datas storaged in cache for my MBO? I have read that I can use getMessageValueCollection in custom.js to access to my datas but once I get the datas, How can associate those datas to a Listview like a online request?? Do i have to develop my own screen in html or how?
    Thanks.

    I'm not entirely clear on what you mean by "cache" in this context.  I'm going to assume that what you are really referring to is the contents of the workflow message, so correct me if I'm wrong.  There is, in later releases, the ability to set an device-side request cache time so that if you issue an online request it'll store the results in an on-device cache and if you subsequently reissue the same online request with the same parameter values within that timeout period it'll get the data from the cache rather than going to the server, but my gut instinct is that this is not what you are referring to.
    To access the data in the workflow message, you are correct, you would call getMessageValueCollection().  It will return an object hierarchy with objects defined in WorkflowMessage.js.  Note that if your online request fails, the data won't magically appear in your workflow message.
    To use the data in the workflow message to update a listview, feel free to examine the code in the listview widgets and in API.js.  You can also create a custom listview as follows:
    function customBeforeNavigateForward(screenKey, destScreenKey) {
         // In this example, we only want to replace the listview on the "My Approvals" screen    
         if (destScreenKey == 'My_Approvals'){
              // First, we get the MessageValueCollection that we are currently operating on
              var message = getCurrentMessageValueCollection();
              // Next, we'll get the list MessageValue from that MessageValueCollection
              var itemList = message.getData("LeaveApprovalItem3");
              // Because its a list, the Value of the MessageValue will be an array
              var items = itemList.getValue();
              // Figure out how many items are in the list
              var numOfItems = items.length;
              // Iterate through the results and build our list
              var i = 0;
              var htmlOutput = '<div><ul data-role="listview" data-theme="k" data-filter="true">';
              var firstChar = '';
              while ( i < numOfItems ){
                   // Get the current item. This will be a MessageValueCollection.
                   var currItem= items<i>;
                   // Get the properties of the current item.
                   var owner = currItem.getData("LeaveApprovalItem_owner_attribKey").getValue();
                   var type = currItem.getData("LeaveApprovalItem_itemType_attribKey").getValue();
                   var status = currItem.getData("LeaveApprovalItem_itemStatus_attribKey").getValue();
                   var startDate = currItem.getData("LeaveApprovalItem_startDate_attribKey").getValue();
                   var endDate = currItem.getData("LeaveApprovalItem_endDate_attribKey").getValue();
                   // Format the data in a specific presentation
                   var formatStartDate = Date.parse(startDate).toString('MMM/d/yyyy');
                   var formatEndDate = Date.parse(endDate).toString('MMM/d/yyyy');
                   // Decide which thumbnail image to use
                   var imageToUse = ''
                        if (status == 'Pending'){
                             imageToUse = 'pending.png';
                        else if (status == 'Rejected'){
                             imageToUse = 'rejected.png';
                        else {
                             imageToUse = 'approved.png';
                   // Add a new line to the listview for this item
                   htmlOutput += '<li><a id ="' + currItem.getKey() + '" class="listClick">';
                   htmlOutput += '<img src="./images/' + imageToUse + '" class="ui-li-thumb">';
                   htmlOutput += '<h3 class = "listTitle">' + type;
                   htmlOutput +=  ' ( ' + owner + ' ) ';
                   htmlOutput += '</h3>';
                   htmlOutput += '<p>' + formatStartDate + ' : ' + formatEndDate + '</p>';
                   htmlOutput += '</a></li>';
                   i++;
              htmlOutput += '</ul></div>';
              // Remove the old listview and add in the new one.  Note: this is suboptimal and should be fixed if you want to use it in production.
              $('#My_ApprovalsForm').children().eq(2).hide();
              $('#My_ApprovalsForm').children().eq(1).after(htmlOutput);
              // Add in a handler so that when a line is clicked on, it'll go to the right details screen
              $(".listClick").click(function(){
                   currListDivID = $(this).parent().parent();
                   $(this).parent().parent().addClass("ui-btn-active");
                   navigateForward("Request_Details",  this.id );
                   if (isBlackBerry()) {
                        return;
         // All done.
         return true;

  • How to load and display the external flv video files in dynamicly and the how to control the flv fil

    How to load and display the external flv video files in dynamicly using AS 3.0
    and  How to control the flv file  add the play paus button and add seekbar.
    I have using to load the flv file following code
    var flvPlaceHolder1:MovieClip = new MovieClip();
    var vid1:Video = new Video(734, 408);
    flvPlaceHolder1.addChild(vid1);
    addChild(flvPlaceHolder1);
    flvPlaceHolder1.x = 1059;
    flvPlaceHolder1.y = 152;
    var nc1:NetConnection = new NetConnection();
    nc1.connect(null);
    var ns1:NetStream = new NetStream(nc1);
    vid1.attachNetStream(ns1);
    var listener1:Object = new Object();
    listener1.onMetaData = function(evt:Object):void {};
    ns1.client = listener1;
    ns1.play("GV-1600 TURNING.flv");
    ns1.addEventListener(NetStatusEvent.NET_STATUS, statusChanged1);
    function statusChanged1(ns1:NetStatusEvent):void
             trace(ns1.info.code);
            if (ns1.info.code == 'NetStream.Buffer.Empty')
                 trace('the video has ended');
                 removeChild(flvPlaceHolder1);
                 //trace('removeChild');
                gotoAndPlay(1786);
    then how to add the play,paus ,full screen button    and   seekbar,volumebar.

    I have to Create the flash presentation for our company product
    In this presentation the left  side the text animation are displayed then right side the our product video is displayed.
    In this presentation i need the following option :
    1, The first product video and animation is finished then the next product is played
    2, then the video displayed  (size width and height 400x300) , I click this video to increase the size(ex:1000x700)
    3, then the playing video i control  it play, stop, paus button and volume bar, seek bar.
    4, then this presentation is displayed on 42 inches LCD TV so this full presentation is run full screen.
    I have finished first two steps 1 and 2
    the following are the screen short and code:-
    code :-
    var count=0;
    var flvPlaceHolder2:MovieClip = new MovieClip();   
    var vid2:Video = new Video(734, 408);
    flvPlaceHolder2.addChild(vid2);
    addChild(flvPlaceHolder2);
    flvPlaceHolder2.x = 1059;
    flvPlaceHolder2.y = 152;
    var nc2:NetConnection = new NetConnection();
    nc2.connect(null);
    var ns2:NetStream = new NetStream(nc2);
    vid2.attachNetStream(ns2);
    var listener2:Object = new Object();
    listener2.onMetaData = function(evt:Object):void {};
    ns2.client = listener2;
    ns2.play("GS-4000.flv");
    this.addEventListener(Event.ENTER_FRAME, BtnFadeIn2);
    function BtnFadeIn2(event:Event):void
        if (this.currentFrame == 387)
            /*flvPlaceHolder2.x = 30;
            flvPlaceHolder2.y = 140;
            vid2.width=1800;
            vid2.height=800;
            trace('Screen size is changed');*/
            if(count==0)
            flvPlaceHolder2.x = 30;
            flvPlaceHolder2.y = 140;
            vid2.width=1800;
            vid2.height=800;
            count++;
    ns2.addEventListener(NetStatusEvent.NET_STATUS, statusChanged2);
    function statusChanged2(ns2:NetStatusEvent):void
        trace(ns2.info.code);
        if (ns2.info.code == 'NetStream.Buffer.Empty')
                trace('the video has ended');
                 removeChild(flvPlaceHolder2);
                 //trace('removeChild');
                gotoAndPlay(433);
    flvPlaceHolder2.buttonMode=true;
    flvPlaceHolder2.addEventListener(MouseEvent.CLICK,home2);
    function home2(e:MouseEvent):void
        if(vid2.width==734 && vid2.height==408)
            flvPlaceHolder2.x = 30;
            flvPlaceHolder2.y = 140;
            vid2.width=1800;
            vid2.height=800;
        else
            flvPlaceHolder2.x = 1059;
            flvPlaceHolder2.y = 152;
            vid2.width=734;
            vid2.height=408;

  • How to Generate and Display SVG Graphics in ABAP

    Hi everybody,
    I tried to complete the Tutorial "How to Generate and Display SVG Graphics in ABAP, Part 1" by Siarhei Ulasenka (https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/ad83a990-0201-0010-d680-a189f8bc20fa).
    Unfortunately when I tried the example to display an SVG Drawing in an ABAP Report I get the error message "Es ist ein Laufzeitfehler aufgetreten, ungültiges Zeichen" (english should be something like "Runtime Error, unkown character"). But it works when I open the svgfile in a new IE Window (parameter in_place from cl_gui_html_viewer->show_url). Also when I open a svg file from the local disc it works fine.
    The code:
        CALL METHOD html_control->load_data
          EXPORTING
            url            = 'chart.svg'
            type         = 'image'
            subtype    = 'svg+xml'
          CHANGING
            data_table = lt_svg
          EXCEPTIONS
            OTHERS     = 1.
        CALL METHOD html_control->show_url
          EXPORTING
            url        = 'chart.svg'
            in_place   = 'X'
          EXCEPTIONS
            cntl_error = 1.
    Has anyone a solution? Thanks in advance for your help!
    Regards
    Kathrin

    Hello Alex,
    The Corel SVG viewer has problems loading and displaying the examples (see the list of limitations at their site). Try to use the Adobe viewer instead.
    Regards,
    Sergei Ulasenka

  • How to decode and display jpeg from a bytes stream ?

    Hello.
    I am new to Flex and got stuck on something that I assume has an easy solution.
    I have an RIA application in which I want to display a jpeg image. this image was
    sent on a Web Service message,  as an array of bytes (I just read the jpeg file as
    is and send it to the web application).
    I couldn't figure out a way to decode and display this image at the RIA, using an apropriate component. (Image ?)
    I have seen a few examples where a jpg is loaded from a web server using a url in
    which it's avaliable, but I don't think this is much help to me...
    Your help/example apreciated.

    Thanks.
    I assume you mean passing the bytesArray to Image.load() ?
    Anyway, that's what I did and it worked fine.
    Now I am facing the same issue with playing sounds, which are available on bytesArray.
    I tried to pass the mp3 bytes to the Sound.load(), but it doesn't work, becuase it tries
    to cast it to a URL. do you know by any chance  whether I can achieve that somehow ?
    (I could use prety much any other sound format, if it makes a difference)
    Thanks again.

  • How to get and display current year

    hi,
    how to get and display current year
    and need it to convert numeric format if it is orginally
    in character format.

    Hi,
    chk this FM.
    CALL FUNCTION 'GET_CURRENT_YEAR'
      EXPORTING
        BUKRS         = '1000'     " Company Code
        DATE          = SY-DATUM   " Date to find fiscal year for
      IMPORTING
        CURRM         = w_currm    " Current Fiscal Month
        CURRY         = w_curry    " Current Fiscal Year
        PREVM         = w_prevm    " Previous Fiscal Month
        PREVY         = w_prevy.   " Previous Fiscal Year
    rgds
    anver
    if hlped pls mark points

  • Firefox can't load a Siemens Gigaset network camera but IE8 can. There is an error in the code from the cam. Could Firefox ignore this and display the image anyway ? eg. with Ignore / Abort.

    I run Windows-XP SP3 and I can't get the image from a Siemans Gigaset cam. There is an error in the cam code (a lacking rutine) . IE8 ignores this and displays the image anyway.
    Is it possible to get a notification like Ignore/Abort/ Continue ???

    Does the documentation for that camera, or for the software with it, say anything about ActiveX or about H.264?
    If so, it isn't compatible with Firefox - it doesn't do ActiveX and it doesn't support H.264 in the HTML5 standard. Microsoft just released a plugin for Firefox that adds H.264 support to Firefox, but IIRC that only covers Windows 7 - not WinXP.

  • My lov returns AND displays the return value

    Hi,
    For 1 of the columns I'm representing in APEX, I choose 'Display as text, based on a lov'. I'm using:
    select aan.id||', '||r.naam||', '||a.woonplaats d, aan.id r
    from wmo_aanvragen aan
    , wmo_dossiers d
    , wmo_relaties r
    , wmo_adressen a
    where d.avg_1_id = aan.id
    and d.rel_nummer = r.nummer
    and a.rel_nummer = r.nummer
    and a.id = (select min(e.id) from wmo_adressen e where e.REL_NUMMER = r.nummer
    and e.EIND_DATUM is null)
    and d.id = (select min(f.id) from wmo_dossiers f where f.AVG_1_ID = aan.id)
    But somehow it returns AND displays the 'aan.id' value instead of displaying the display value. Does anyone know howcome?? In TOAD it works fine. Starting a new page also doesn't make any sense
    Niels

    Nope, doesn't work either.
    I've an identical statement which does work...
    select z.id||', '||zst.omschrijving||', '||r.naam||', '||a.woonplaats d, z.id r
    from wmo_zorgverleners z
    , wmo_zorgverlener_soorten zst
    , wmo_relaties r
    , wmo_adressen a
    where z.zst_id = zst.id
    and z.rel_nummer = r.nummer
    and a.rel_nummer = r.nummer
    and a.id = (select min(e.id)
    from wmo_adressen e
    where e.REL_NUMMER = r.nummer
    and e.EIND_DATUM is null)
    Here,iIt does display the contcatenated text..

  • Browser can resolve, access, and display JPEG image, but ImageIcon can't.

    I've got this weird problem that only happens with images accessed through a customer's VPN:
    Microsloth Internet Imploder can resolve, access, and display a JPG image from a VPN URL, in the general form:
    http://intranet/part?FOOBAR.JPG which the browser apparently transmogrifies into
    http://mogrify.foo.com/images/scripts/cgi/detail.cgi?FOOBAR.JPG(as Jack Webb often said, the names have been changed to protect the innocent)
    Firefox can also resove, access, and display the image.
    But an ImageIcon, when fed either URL, quietly fails to get anything, No errors, no exceptions, but no image, either.
    The application, if it detects the failure of ImageIcon to come up with the image, somehow (not my code) defers to "Windoze Image and Fax Viewer," which locks up trying to resolve, access, and display the image.
    What could possibly be going on here?

    I'd love to have the luxury of saying, "You lost me at Windoze." Then again, to paraphrase a running gag from Airplane!, it looks like I picked the wrong week to quit hemlock.
    As my final message on my other thread on this topic indicates, the problem is that even though the URL ends in JPG, the server isn't really serving up a JPEG, but rather, an HTML page containing the JPEG.
    Knowing this, a solution (of sorts) presented itself: if the URL doesn't produce a displayable ImageIcon, try constructing a JEditorPane on the URL. The results aren't exactly pretty, and you do have to try the ImageIcon first, but it does work.
    JHHL

  • How to organize and resuse my image resources and icons

    Hi JDeveloper experts,
    How to organize and resuse my image resources and icons JDeveloper IDE and deployed system.

    Thanks for answer Timo,
    My JDeveloper edition "Studio Edition Version 11.1.2.0.0" .
    I'm developing web application with BC + ADF + SQL92 compatible database.
    What is the generic java solution or BC + ADF solution for reuse and organize icons, images, resource libraries ?

Maybe you are looking for

  • Move negative sign (minus) to left side of value in gui_download

    Hi, While downloading data using gui_download I want to bring the negative sign to the left side of the value. Is this possible? Regrads, Madhu

  • Report - Grouping of Vendors

    Hi Gurus, I have a doubt on Grouping can anyone please help me regarding this. The issue is i displayed the vendors and many materials they are supplying like Vendor, No.of Material 100, 5 200, 11 1000, 25 and so on.................... Now i want to

  • Search Agenda as in Calendar Client

    Hi, We would like to have the search through agenda entries as it is implemented in Calendar client (search word between entry dates). Do you know if is possible to develop it using the APIs and how? It is also possible to add this new search over Ca

  • Firefox and adobe interactive forms

    Hi, I am trying to get a web dynpro application to work on Firefox 1.5. When I ran the application the first time in IE I got a popup asking to install a java object. I refused and got an error message in the browser saying it could not render the fo

  • WDA - Testing application URL Error

    Hello Gurus, I am new to Webdynpro environment, followed step by step approach as in the tutorial and created an application. When tried to activate and test the application, There was an error " The URL was not call due to an error". Please help me