Display images on QueryString NULL

Hi,
I have an image gallery with two tables, one with the Image
information and the other with the Categories.
How can I show all the images when my Request.QueryString is
NULL ?
Right now it is giving me a default value "1" and only
showing me that Category.

HI,
Please find the below code.
CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
    EXPORTING
      p_object       = c_graphics
      p_name         = lv_logo
      p_id           = c_bmap
      p_btype        = c_bcol
    RECEIVING
      p_bmp          = GV_LOGO
    EXCEPTIONS
      not_found      = 1
      internal_error = 2
      OTHERS         = 3.
Go to adobe form context and create graphic and change the property graphic type as graphic Content and assign field as gv_logo and mime type as 'BMAP'.
In the layout select image field and bind it.
Thanks & Regards,
Hemachandran.R

Similar Messages

  • Display Image based on DropDownList C# ASP

    Hello,
    So I basically created SQL Server Database and I got it working with displaying my images and drop downlist and everything, however, I want to make it to display an image only if a continent is selected. So if I select Europe, I would like to receive a picture
    and short description. Any ideas how can I add the description as well?
    So something like:
    if(ddlContinents.SelectedValue = "Europe) display image 1"
    protected void Page_Load(object sender, EventArgs e)
    if (Request.QueryString["ImageID"] != null)
    string strQuery = "select Name, ContentType, Data from tblFiles where id=@id";
    SqlCommand cmd = new SqlCommand(strQuery);
    cmd.Parameters.Add("@id", SqlDbType.Int).Value = Convert.ToInt32(Request.QueryString["ImageID"]);
    DataTable dt = GetData(cmd);
    if (dt != null)
    Byte[] bytes = (Byte[])dt.Rows[0]["Data"];
    Response.Buffer = true;
    Response.Charset = "";
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.ContentType = dt.Rows[0]["ContentType"].ToString();
    Response.AddHeader("content-disposition", "attachment;filename=" + dt.Rows[0]["Name"].ToString());
    Response.BinaryWrite(bytes);
    Response.Flush();
    Response.End();
    if (!IsPostBack)
    ddlContinents.AppendDataBoundItems = true;
    String strConnString = ConfigurationManager
    .ConnectionStrings["conString"].ConnectionString;
    String strQuery = "select ID, ContinentName from Continents";
    SqlConnection con = new SqlConnection(strConnString);
    SqlCommand cmd = new SqlCommand();
    cmd.CommandType = CommandType.Text;
    cmd.CommandText = strQuery;
    cmd.Connection = con;
    try
    con.Open();
    ddlContinents.DataSource = cmd.ExecuteReader();
    ddlContinents.DataTextField = "ContinentName";
    ddlContinents.DataValueField = "ID";
    ddlContinents.DataBind();
    catch (Exception ex)
    throw ex;
    finally
    con.Close();
    con.Dispose();
    private DataTable GetData(SqlCommand cmd)
    DataTable dt = new DataTable();
    String strConnString = System.Configuration.ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
    SqlConnection con = new SqlConnection(strConnString);
    SqlDataAdapter sda = new SqlDataAdapter();
    cmd.CommandType = CommandType.Text;
    cmd.Connection = con;
    try
    con.Open();
    sda.SelectCommand = cmd;
    sda.Fill(dt);
    return dt;
    catch
    return null;
    finally
    con.Close();
    sda.Dispose();
    con.Dispose();
    public void ddlCity_SelectedIndexChanged(object sender, EventArgs e)
    lblResults.Text = "You Selected " +
    ddlContinents.SelectedItem.Text + " -----> " +
    ddlCountry.SelectedItem.Text + " -----> " +
    ddlCity.SelectedItem.Text;
    public void ddlContinents_SelectedIndexChanged(object sender, EventArgs e)
    var continent = ddlContinents.SelectedValue;
    ddlCountry.Items.Clear();
    ddlCountry.Items.Add(new ListItem("--Select Country--", ""));
    ddlCity.Items.Clear();
    ddlCity.Items.Add(new ListItem("--Select City--", ""));
    ddlCountry.AppendDataBoundItems = true;
    String strConnString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
    String strQuery = "select ID, CountryName from Countries where ContinentID=@ContinentID";
    SqlConnection con = new SqlConnection(strConnString);
    SqlCommand cmd = new SqlCommand();
    cmd.Parameters.AddWithValue("@ContinentID", ddlContinents.SelectedItem.Value);
    cmd.CommandType = CommandType.Text;
    cmd.CommandText = strQuery;
    cmd.Connection = con;
    try
    con.Open();
    ddlCountry.DataSource = cmd.ExecuteReader();
    ddlCountry.DataTextField = "CountryName";
    ddlCountry.DataValueField = "ID";
    ddlCountry.DataBind();
    if (ddlCountry.Items.Count > 1)
    ddlCountry.Enabled = true;
    else
    ddlCountry.Enabled = false;
    ddlCity.Enabled = false;
    catch (Exception ex)
    throw ex;
    finally
    con.Close();
    con.Dispose();
    <table> <tr> <td align = "center"> <<asp:image ToolTip = "ASP Image Control" ID="Image1" runat="server" ImageUrl ="Default.aspx?ImageID=1" Height="156px" Width="174px"></asp:image></td> <td align = "center"><<asp:image ToolTip = "ASP Image Control" ID="Image2" runat="server" ImageUrl ="Default.aspx?ImageID=2" Height="156px" Width="174px"></asp:image></td> <td align = "center"> <<asp:image ToolTip = "ASP Image Control" ID="Image3" runat="server" ImageUrl ="Default.aspx?ImageID=3" Height="156px" Width="174px"></asp:image></td> </tr> </table>

    Questions related to ASP.NET should be posted in the ASP.NET forums (http://forums.asp.net ).

  • Open and display image in MVC layout

    Hello!
    I cant figure out how I shall do this in an MVC layout:
    The program request user to open an image file that are then displayed in a JLabel
    My setup at the moment resolve in a nullpointerexeption because it dont get any actual image file, but I dont understand what I have missed.
    I can not post the whole code fo you to run because it is to big, so I post the part that are the most important. please have a look.
    PicturePanel
    //Import Java library
    import javax.swing.*;
    import java.awt.*;
    public class PicturePanel extends JPanel {
         //Variables
         private ImageIcon picture;
         //Method to get information of the selected file
         PicturePanel (String fileName) {
              picture = new ImageIcon (fileName); //Get the filename
              int w = picture.getIconWidth(); //Get the image with
              int h = picture.getIconHeight(); //Get the image height
              //Set preferable size for the image (Use the properties for the selected image)
              setPreferredSize(new Dimension(w, h));
              setMinimumSize(new Dimension(w, h));
              setMaximumSize(new Dimension(w, h));
         //Method to draw the selected image
         protected void paintComponent(Graphics g) {
              super.paintComponent(g); //We invoke super in order to: Paint the background, do custom painting.
              g.drawImage(picture.getImage(), 0, 0, this); //Draw the image at its natural state
    }From my model:
    //Local attributes
         boolean check = false; //Used to see if a statement is true or not
         PicturePanel pp;
         JFileChooser fc;
         int returnVal;
    //newFile in File menu
         public void newFile() {
              //Open a file dialog in users home catalog
              fc = new JFileChooser();
              //In response to a button click:
              returnVal = fc.showOpenDialog(pp);
              System.out.println("You pressed new in file menu");
         }From my controler:
    //User press "New" in File menu
              else if (user_action.equals("New")) {
                   //Call method in model class
                   model.newFile();
                   //Update changes
                   if (model.returnVal == JFileChooser.APPROVE_OPTION) {
                        System.out.println("Hello1");
                        File f = model.fc.getSelectedFile();
                        if (model.pp != null)     
                             model.pp = new PicturePanel(f.getAbsolutePath());
                        System.out.println("Hello2");
                        //Display image (Here is line 83)
                        view.setImage_DisplayArea(model.pp);
                        System.out.println("Hello3");
              }From my view:
    //Sets the image to be displayed on the image_display area (Here is line 302)
         public void setImage_DisplayArea(PicturePanel pp) {
              image_display.add(pp);
         }The complet error:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
         at java.awt.Container.addImpl(Container.java:1015)You pressed new in file menu
    Hello1
    Hello2
         at java.awt.Container.add(Container.java:351)
         at View_Inlupp2.setImage_DisplayArea(View_Inlupp2.java:302)
         at Control_Inlupp2.actionPerformed(Control_Inlupp2.java:83)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1882)
         at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2202)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
         at javax.swing.AbstractButton.doClick(AbstractButton.java:334)
         at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1050)
         at apple.laf.CUIAquaMenuItem.doClick(CUIAquaMenuItem.java:119)
         at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1091)
         at java.awt.Component.processMouseEvent(Component.java:5602)
         at javax.swing.JComponent.processMouseEvent(JComponent.java:3129)
         at java.awt.Component.processEvent(Component.java:5367)
         at java.awt.Container.processEvent(Container.java:2010)
         at java.awt.Component.dispatchEventImpl(Component.java:4068)
         at java.awt.Container.dispatchEventImpl(Container.java:2068)
         at java.awt.Component.dispatchEvent(Component.java:3903)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3936)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3866)
         at java.awt.Container.dispatchEventImpl(Container.java:2054)
         at java.awt.Window.dispatchEventImpl(Window.java:1801)
         at java.awt.Component.dispatchEvent(Component.java:3903)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)Edited by: onslow77 on Dec 16, 2009 5:00 PM
    Edited by: onslow77 on Dec 16, 2009 5:04 PM

    Hello again!
    Anyone that can help me figure out how to implement this in an MVC layout, I feel stuck.
    I post a little program that open and display an image file so that you better can understand what I whant to do.
    ShowImage
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.File;
    import javax.swing.filechooser.*;
    public class ShowImage extends JFrame{
         //Variables
         JFileChooser fc = new JFileChooser();
         PicturePanel pp = null;
         ShowImage () {
              super("Show"); //Title
              //Create the GUI
              JPanel top = new JPanel();
              add(top, BorderLayout.NORTH);
              JButton openBtn = new JButton("Open");
              top.add(openBtn);
              openBtn.addActionListener(new Listner());
              //Settings for the GUI
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              pack();
              setVisible(true);
         class Listner implements ActionListener {
              public void actionPerformed(ActionEvent ave) {
                   int answer = fc.showOpenDialog(ShowImage.this);
                   if (answer == JFileChooser.APPROVE_OPTION){
                        File f = fc.getSelectedFile();
                        //Check
                        System.out.println(f);
                        System.out.println(pp);
                        if (pp != null)
                             remove(pp); //Clean so that we can open another image
                        //Check
                        System.out.println(pp);
                        //Set the PicturePanel
                        pp = new PicturePanel(f.getAbsolutePath());
                        //Check
                        System.out.println(pp);
                        //Add PicturePanel to frame
                        add(pp, BorderLayout.CENTER);
                        validate();
                        pack();
                        repaint();
         //Main
         public static void main(String[] args) {
              new ShowImage();
    }PicturePanel
    //Import Java library
    import javax.swing.*;
    import java.awt.*;
    public class PicturePanel extends JPanel {
         //Variables
         private ImageIcon picture;
         //Method to get information of the selected file
         PicturePanel (String fileName) {
              picture = new ImageIcon (fileName); //Get the filename
              int w = picture.getIconWidth(); //Get the image with
              int h = picture.getIconHeight(); //Get the image height
              //Set preferable size for the image (Use the properties for the selected image)
              setPreferredSize(new Dimension(w, h));
              setMinimumSize(new Dimension(w, h));
              setMaximumSize(new Dimension(w, h));
         //Method to draw the selected image
         protected void paintComponent(Graphics g) {
              super.paintComponent(g); //We invoke super in order to: Paint the background, do custom painting.
              g.drawImage(picture.getImage(), 0, 0, this); //Draw the image at its natural state
    }//The endEdited by: onslow77 on Dec 16, 2009 7:30 PM

  • Display image in JPanel without saving any file to disk

    Hi,
    I am fetching images from database. I am saving this image, display in JPanel and delete it. But this is not actually I want.
    I wish to fetch this image as stream , store in memory and display in JPanel without saving any fiel in disk.
    I wonder if it is Possible or any used implementation that I can use in my project. Any idea or experienced knowledge is enough.
    Thanks

    In what format is the image coming to you from the database? If it's an InputStream subclass, just use javax.imageio.ImageIO:
    InputStream in = getImageInputStream();
    BufferedImage image = null;
    try {
       image = ImageIO.read(in);
    } finally {
       in.close();
    // ... Display image in your JPanel as you have beenIf you receive the image as an array of bytes, use the same method as above, but with a ByteArrayInputStream:
    byte[] imageData = getImageData();
    ByteArrayInputStream in = new ByteArrayInputStream(imageData);
    BufferedImage image = null;
    try {
       image = ImageIO.read(in);
    } finally {
       in.close();
    // ... Display image in your JPanel as you have been

  • Display image in standalone AIR application

    I have loaded images and like to display image in standalone AIR application. But I cannot get it work. The code as follows:
    private function ImageLoader(url:String):void
    var request:URLRequest = new URLRequest(url);
    var loader:Loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderComplete);
    loader.load(request);    
    private function loaderComplete(event:Event):void
    var scaleFactor:Number = 1;
    var uic:UIComponent = new UIComponent();
    try
    var bmp:Bitmap = event.target.content as Bitmap;
    var bmd:BitmapData = bmp.bitmapData; //Bitmap(event.target.content).bitmapData;
    var scaledBMD:BitmapData = new BitmapData(400, 400);
    var matrix:Matrix = new Matrix();
    matrix.scale(scaleFactor, scaleFactor);
    scaledBMD.draw(bmd, matrix, null, null, null, true);
    uic.x = 40;
    uic.y = 40;
    uic.addChild(new Bitmap(scaledBMD));
    catch (errObject:Error)
    trace(errObject.message);

    Found answer by adding mx:Canvas and add
    iconCanvas.addChild(uic);
    after
    uic.addChild(new Bitmap(scaledBMD));
    <mx:Canvas id="iconCanvas" width="10" height="10" horizontalScrollPolicy="off" verticalScrollPolicy="off" x="0" y="0" clipContent="false"/>
    Is anyone create "Canvas" by using new Canvas and get it works? example:
    var canv:Canvas = new Canvas(...);

  • JDeveloper 11g Using jsp to display images

    I am converting a 10.1.3.3 application to 11.1.1.3
    It has 2 web modules. One is an ADF administrator module and the other is a public web that displays information including images stored as blobs.
    This public module has a simple technology scope, only html, java, jsp and servlets. It is a hand me down from a few technologies ago and ran well on 10.1.3.3
    To display images it uses a jsp acting as a servlet which is referenced inside other jsps. Since moving to 11g the images no longer display. If I use a java class servlet it works
    however I have to use the full url, e.g. http://mydomain:myport/web/Sevlet?.... which means I have to update the details for each deployment.
    I can use <h:graphicImage but this means I have to include JSF and use expression language to fill in the servlet parameters.
    I don't know what has changed to cause it to fail. Weblogic?
    The Libraries and Classpath include
    JSP Runtime
    Servlet Runtime
    JSTL 1.2
    The servlet jsp is as follows remembering it works in 10.1.3.3
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="javax.naming.Context" %>
    <%@ page import="java.io.*" %>
    <%@ page import="userinterface.util.ByteArray" %>
    <%@ page import="userinterface.online.ImageUIHelper" %>
    <%@ page import="userinterface.online.ImageUIHelperValue" %>
    <%
         String dataObjectId = "";
         String regionId = "";
         boolean getObjectImage=false;
         boolean getRegionImage=false;
         // determine which type of image to retrieve
         if (request.getParameter("dataObjectId") != null)
              dataObjectId = request.getParameter("dataObjectId").toString();
              getObjectImage=true;
         } else if (request.getParameter("regionId") != null)
              regionId = request.getParameter("regionId").toString();
              getRegionImage=true;
         if (getObjectImage==true || getRegionImage == true)
              try
                   ImageUIHelper imageHelper = new ImageUIHelper();
                   ImageUIHelperValue vo = null;
                   if (getObjectImage)
                        vo = imageHelper.doReadObjectImage(new Integer(dataObjectId));
                   } else if (getRegionImage)
                        vo = imageHelper.doReadRegionImage(new Integer(regionId));
                   if (vo != null && vo.getImage() != null)
                        // determine the mimetype
                        String mimeType="image/png";
                        if (vo.getFilename().toLowerCase().endsWith(".gif"))
                             mimeType = "image/gif";
                        else if (vo.getFilename().toLowerCase().endsWith(".jpg"))
                             mimeType = "image/jpg; charset=windows-1252";
                        else if (vo.getFilename().toLowerCase().endsWith(".png"))
                             mimeType = "image/png";
                        else if (vo.getFilename().toLowerCase().endsWith(".bmp"))
                             mimeType = "image/bmp";
                        response.setContentType(mimeType);
                        response.setHeader("pragma", "no-cache");
                        ServletOutputStream os = response.getOutputStream();
    os.write(vo.getImage().getBytes());
                        os.flush();
                        os.close();
              } catch (Exception ex)
    A simple test harness follows. The actual pages substitute the java values using <%= uri %> as below
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%
    String uri = "http://localhost:7101/publicweb/img/ImageServlet?imageType=dataObject&dataObjectId=822";
    String uri2 = "ImageServlet.jsp?dataObjectId=822";
    String uri3 = "ImageServlet.jsp?dataObjectId=694";
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
    <title>testServlet</title>
    </head>
    <body>
    <table cellspacing="2" cellpadding="3" border="1" width="100%">
    <tr>
    <td width="20%">Checking Servlet</td>
    <td width="80%"><img src=<%= uri %>
    id="imge"
    width="400px" alt="Image" />
    </td>
    </tr>
    </table>
    </body>
    </html>

    i responded to your duplicate message 4 days ago:
    is it possible to insert and retrieve images from sql server using actionscript.
    you'll need server-side script to query your database and you can use the flash urlloader class to call your script.
    also  is it possible to create a flash scrolling gallery based on images  stored in a database and everytime an image is added it is displayed in  the gallery.
    load the data using the urlloader class and  then load the images.  periodically query the database for new images if  there's no direct way for flash to know a new image was added.

  • Problem in displaying images

    Dear JSP/Servlet experts,
    I have problem in displaying images on a JSP page. I stored all the images names in a database and
    try to retrieve them based on the user selection. When the JSP page is load for the first time the
    following error occur but the images are displayed correctly:
    2002-08-07 04:40:15 - Ctx( /simple ): IOException in: R( /simple + /images/cover150.jpg + null) Connection aborted by peer: socket write error
    2002-08-07 04:40:15 - Ctx( /simple ): IOException in: R( /simple + /images/cover154.jpg + null) Connection aborted by peer: socket write error
    2002-08-07 04:40:15 - Ctx( /simple ): IOException in: R( /simple + /images/cover152.jpg + null) Connection aborted by peer: socket write error
    2002-08-07 04:40:15 - Ctx( /simple ): IOException in: R( /simple + /images/cover151.jpg + null) Connection aborted by peer: socket write error
    2002-08-07 04:40:15 - Ctx( /simple ): IOException in: R( /simple + /images/cover156.jpg + null) Connection aborted by peer: socket write error
    Here is the code to display the images(the getCover() method will return cover150.jpg, cover151.jpg.... )
    and the images are stored in /simple/images folder
    <td><a href="<img src="/simple/images/<%= b.getCover() %>" alt="details"></td>

    try this
    <img src=/simple/images/<%=b.getCover() %>
    vasanth

  • Having trouble displaying images on a page in APEX through IE.

    I'm trying to conditionally display images (used as toggle buttons) in a tabular report in APEX. This is for our Benefits application where an employee can include or exclude his/her dependents from the plan. For each row, in one column I want to show only 'Include' button if an individual is not already a member, and in another column show only 'Remove' button if already included. I'm using the button images as links and passing information to a page process.
    I was able to come up with the SQL query which works perfectly fine in Firefox. But the images won't display in Internet Explorer. Does anyone have any idea how to make this work in IE?
    Below is my query. This code will display 'Include in plan' image only if the member is not already added to the plan. If 'Y' is the result of the query, then the member is already included and no image is displayed. Otherwise display the image. Pass the member_id to an application item and process the record in a Before Header process.
    select elected_member_id, member_type, last_name, first_name, middle_name, gender,date_of_birth,student_flag,trunc(months_between(sysdate ,date_of_birth)/12) AGE,
    decode((select 'Y'
    from eben_elected_plan_info epi
         where plan_name not in ('Delta', 'Vision', 'HEALTH_FLEX', 'DEP_FLEX')
         and epi.elected_member_id = emi.elected_member_id
         and transaction_type <> 'END'), null,'<a href="f?p=&APP_ID.:70:&SESSION.::::F_APP_MEMBER_INCLUDE:'||elected_member_id||'<img src="&WORKSPACE_IMAGES.include.png"></a>') elected_member_id_include,
    elected_member_id elected_member_id_exclude
    from eben_elected_members_info emi
    where emp_person_id = :f_app_person_id
    and member_type <> 'Employee'

    I was able to resolve this issue by creating the SQL statement from scratch in IE. It then recognized the images.

  • Displaying images in their own format.

    I wrote the following code to store a path of an image into a textbox:
    declare
    filename VARCHAR2(255);
    begin
    filename := GET_FILE_NAME(NULL,NULL,'All Files (*.*)|*.*|');
    :infiles.letterpath := filename;
    end;
    Then,
    I used the following code to read an image(bath) from "letterpath" textbox and display it into an image item:
    Read_image_file(:infiles.letterpath, 'gif', 'infiles.letter_image');
    Now, what i want is to show images in their own format, not to dispaly them into an image item.
    Can someone please tell me how i can display images in their own format.
    For example: lets say i store a path of a word document in a textbox then when i click an open button, i want that document to be displayed in MS Word.
    Thanks in advance.

    Hi,
    you could use an OLE container in Forms and associate this with the externmal viewer that you would like to show the source. This however works for c/s and immediately stops working once moving your app to the Web. There you would need to investigate in a Java Bean solution to do this.
    Frank

  • Displaying images in canvas one after another

    Hi all,
    I have a problem displaying images in canvas one after another. I am using for loop and when i run the application, all images run back in the and only finally only the last image gets displayed in the emulator. I also used thread.sleep(). But it din't work.
    Here is my code:
    // A canvas that illustrates image drawing
    class DrawImageCanvas extends Canvas
    Image image;
    public void paint(Graphics g)
    int width = getWidth();
    int height = getHeight();
    g.setColor(0);
    g.fillRect(0, 0, width, height);
    String images[]={"paint_2.PNG","radha.PNG","cute.png","design.png","flowers.png"};
    for(int i=0;i<images.length;i++)
    image = null;
    System.out.println("/"+images);
         try
         image = Image.createImage("/"+images[i]);
    catch (IOException ex)
    System.out.println(ex);
    g.setColor(0xffffff);
    g.drawString("Failed to load image!", 0, 0, Graphics.TOP | Graphics.LEFT);
    return;
    if (image != null)
    g.drawImage(image, width/2, height/2, Graphics.VCENTER | Graphics.HCENTER);
    try
    Thread.sleep(5000);
    catch(Exception ex)
         System.out.println("the exception is.."+ex);
    Help me and Thanks in advance.

    See the code below : prefer the use of a Timer and a TimerTask instead of Thread.sleep().
    showNotify (from Canvas) is used to launch the timer.
    import java.io.IOException;
    import java.util.Timer;
    import java.util.TimerTask;
    import javax.microedition.lcdui.Canvas;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.Image;
    public class DrawImage extends Canvas {
        Image image;
        String images[] = {"img1.png", "img2.png", "img3.png", "img4.png", "img5.png",
                            "img6.png", "img7.png"};
        Image[] tabImage;
        int imageCounter = 0;
        public DrawImage(){
            try {
                tabImage = new Image[images.length];
                for (int i = 0; i < images.length; i++)
                    tabImage[i] = Image.createImage("/" + images);
    } catch (IOException ex) {
    ex.printStackTrace();
    public void paint(Graphics g) {
    int width = getWidth();
    int height = getHeight();
    g.setColor(0);
    g.fillRect(0, 0, width, height);
    image = tabImage[imageCounter];
    if (image != null)
    g.drawImage(image, width / 2, height / 2, Graphics.VCENTER | Graphics.HCENTER);
    else{
    System.out.println("null");
    g.setColor(0xffffff);
    g.drawString("Failed to load image!", 0, 0, Graphics.TOP | Graphics.LEFT);
    protected void showNotify(){
    Timer t = new Timer();
    t.schedule(new PhotoSwitcher(), 5000, 5000);
    private class PhotoSwitcher extends TimerTask{
    public void run() {
    if (imageCounter < images.length - 1)
    imageCounter++;
    else
    imageCounter = 0;
    repaint();
    I hope this will help you !
    fetchy.
    Edited by: fetchy on 14 ao�t 2008 09:48                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Display image from database with jspSmart

    Hi
    I have successfully uploaded and saved images into oracle(8.1.5) table DATA_TYPE(dtid number, iconname varchar2(30), icon blob). When I try to display a specific icon in my browser, I get "javax.servlet.ServletException: General error" at:
    PreparedStatement pstmt = myConnection.prepareStatement(mySQL);
    My code looks like this:
    imgModifyDataType.jsp
    <%
    ResultSet myResultSet = null;
    Statement myStatement = null;
    Connection myConnection = null;
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
    myConnection = DriverManager.getConnection("Jdbc:Odbc:Te","te","te");
    String iconName;
    String pDTID = request.getParameter("dtid");
    String mySQL = "Select iconname, icon from data_types where dtid=?";
    PreparedStatement pstmt = myConnection.prepareStatement(mySQL);
    pstmt.setString(1,pDTID);
    myResultSet = pstmt.executeQuery();
    iconName = myResultSet.getString("iconname");
    myUpload.initialize(pageContext);
    myUpload.downloadField(myResultSet,"icon","application/x-msdownload", iconName);
    %>
    I call this JSP from another JSP like this:
    <img src="imgModifyDataType.jsp?dtid=<%=pDTID%>">
    If we cannt display image with the help of another jsp like this then please guide me how to modify the imgModifyDataType.jsp to a servlet because I have never worked in servlets.
    Please help
    Sajid

    I think that it may help you get image from database. I used two jsp page. First one is getphoto.jsp that makes as table based in sql statment and invoke the getimage.jsp this last returns images based on
    the getphoto.jsp PhotoId.
    /** getphoto.jsp source code */
    <%@page import="java.sql.*,oracle.jdbc.*"%>
    <html>
    <head>
    <title>
    jsp1
    </title>
    </head>
    <body bgcolor="#ffffff">
    <table width="781" border="2">
    <tr<<td>
    <td width="83" bgcolor="#C0C0C0"><b>PhotoId</b><td width="450" bgcolor="#C0C0C0"><b>Description</b></td><td width="228" bgcolor="#C0C0C0"><b>Photo Image</b></td>
    <%
    Connection conn = null;
    Statement stmt = null;
    ResultSet rset = null;
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    conn = DriverManager.getConnection("jdbc:oracle:thin:@itas:1521:oraITAS","yourDbUserId","yourDbPassword");
    stmt = conn.createStatement();
    rset = stmt.executeQuery("select photo_id,photo_description from photo");
    while (rset.next()) {
         %>
         <tr><td width="83"><%=rset.getObject("photo_id")%></td><td width="450"><%=rset.getObject("photo_description")%></td><td width="228"><img src="getimage.jsp?PhotoId=<%=rset.getObject("photo_id")%>" width="238" height="228"></td></tr>
         <%
    conn.close();
    %>
    </table>
    </body>
    </html>
    /** getimage.jsp source code */
    <%@ page contentType="image/jpeg; chaoResult=iso-8859-1" language="java" import="java.sql.*,java.io.*,java.util.*" errorPage="" %>
    <%
    String strConnString = null;
    Connection oDbConn;
    Statement oStmt;
    ResultSet oResult;
    String strConnection = null;
    String strUserId = "c_erober";
    String strUserPwd = "sybdev99";
    String strDatabase = "oraITAS";
    String strPhotoId;
    strConnString = "jdbc:odbc:" + strDatabase;
    String strSql;
    try {
    strPhotoId = (String) request.getParameter("PhotoId");
    strSql = "select photo_image from photo" + ( (strPhotoId==null) ? " where photo_id = '001'": (" where photo_id = '" + strPhotoId + "'") );
    DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());
    oDbConn = DriverManager.getConnection(strConnString,strUserId,strUserPwd);
    response.setContentType("image/jpeg");
    oStmt = oDbConn.createStatement();
    oResult = oStmt.executeQuery(strSql);
    oResult.next();
    byte[] bytearray = new byte[4096];
    int size=0;
    InputStream sImage;
    sImage = oResult.getBinaryStream(1);
    response.reset();
    response.setContentType("image/jpeg");
    response.addHeader("Content-Disposition","filename=getimage.jpeg");
    while((size=sImage.read(bytearray))!= -1 ) {
    response.getOutputStream().write(bytearray,0,size);
    response.flushBuffer();
    sImage.close();
    oDbConn.close();
    } catch (SQLException ex) { ex.getMessage();
    %>

  • Help with displaying images (gif, jpeg...) within a JFrame (or similar)

    Hi all,
    i'm new to the forum and i'll be granted if you kind gentlemen/women could use some advices for my gui home application.
    My purpose is to display a static image in a container (i'd prefer to use javax.swing objects, but if you think that java.awt is more suitable for my app, please feel free to tell me about...). I used a modified code from one of the Java Tutorial's examples, tht actually is an applet and displays images as it is using the paint() method. I just can't realize how to set the GraphicContext in a JFrame or a JPanel to contain the image to display, without using applets. Following part of the code I use (a JButton will fire JApplet start, JApplet is another class file called Apple.java):
    class DMToolz extends JFrame {
         private static final long serialVersionUID = 1L;
         private JPanel jContentPane = null;
         private JButton jButton = null;
         private JComboBox jComboBox = null;
         private JMenuItem jMenuItem = null;
         private JMenuBar jJMenuBar = null;
         private JMenu jMenu = null;
         private JMenu jMenu1 = null;
         public int w=10, h=10;
         public String filename;
          * @throws HeadlessException
         public DMToolz() throws HeadlessException {
              // TODO Auto-generated constructor stub
              super();
              initialize();
         public DMToolz(String arg0) throws HeadlessException {
              super(arg0);
              // TODO Auto-generated constructor stub
              initialize();
          * This method initializes jButton
          * @return javax.swing.JButton
         private JButton getJButton() {
              if (jButton == null) {
                   jButton = new JButton();
                   jButton.setBounds(new Rectangle(723, 505, 103, 38));
                   jButton.setText("UrcaMado'");
                   jButton.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent e) {
    /**************SCRIVERE QUI IL NOME DEL FILE CON L'IMMAGINE DA CARICARE*******************/
                             filename = "reference table player2.gif";
                           java.net.URL imgURL = DMToolz.class.getResource("images/"+filename);
                           BufferedImage img = null;
                           try {
                                img =  ImageIO.read(imgURL);
                               w = img.getWidth();
                               h = img.getHeight();
                               System.out.println("*DM* Immagine letta - W:"+w+" H:"+h);
                            } catch (Exception ex) {System.out.println("*DM* Immagine non letta");}
                           JApplet a = new Apple();
                           a.setName(filename);
                           JFrame f = new JFrame ("UrcaBBestia!");
                           f.addWindowListener(new WindowAdapter() {
                               public void windowClosing(WindowEvent e) {System.exit(0);}
                           f.getContentPane().add(a);
                           f.setPreferredSize( new Dimension(w,h+30) );//30 � (circa) l'altezza della barra del titolo del frame
                               f.pack();
                             f.setVisible(true);                      
              return jButton;
    public class Apple extends JApplet {
         private static final long serialVersionUID = 1L;
        final static Color bg = Color.white;
        final static Color fg = Color.black;
        final static Color red = Color.red;
        final static Color white = Color.white;
        public void init() {
            //Initialize drawing colors
            setBackground(bg);
            setForeground(fg);
        public void paint(Graphics g) {
            Graphics2D g2 = (Graphics2D) g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            try {
                 String filename = this.getName(); //uso il nome dell'applet come riferimento al nome del file da caricare
                 java.net.URL imgURL = DMToolz.class.getResource("images/"+filename);
                 BufferedImage img =  ImageIO.read(imgURL);
                 if (img.equals(null)) {System.out.println("IMG null!");System.exit(0);}
                System.out.println("IMG letta");
                int w = img.getWidth();
                int h = img.getHeight();
                resize(w,h);
                g2.drawImage(img,
                            0,0,Color.LIGHT_GRAY,
                            null);// no ImageObserver
             } catch (Exception ex) {ex.printStackTrace();
                                          System.out.println("Immagine non letta.");System.exit(0);}
    }//end classPlease never mind about some italian text, used as reminder....
    Thanks in advance.

    Read the Swing tutorial on "How to Use Labels" or "How to Use Icons" for working examples:
    http://java.sun.com/docs/books/tutorial/uiswing/TOC.html
    By the way you should never override the paint() method. Custom painting (not required in this case) is done by overriding the paintComponent(...) method in Swing. Overriding paint() is an old AWT trick.

  • Display image from image path (ASP)

    Help needed please. Sorry if the topic has already been
    discussed. I did a search but it returned nothing.
    My problem.
    I can display images on my website by choosing the datasource
    and the image path from by database. No issues here. What I want is
    to be able to open up a larger image by clicking on this image.
    I created another page. On this page is an image placeholder.
    The source again is the datasource with the image path to a larger
    image. I used a behaviour to open this page however, it shows the
    same image (the 1st record in my recordset) whichever image you
    click on my origianl page.
    Can someone please tell me how to do it? It would be
    appreciated.

    I'm assuming that you are using a repeat region to display
    the original
    images.
    You will need to pass the Primary Key to the new page, and
    filter the
    recordset on the new page based on that Primary Key.
    For example, this would be the link to the new page:
    <a
    href="page2.asp?ID=<%=(rsImages.Fields.Item("ImageID").Value)%>"
    Then on the new page filter the recordset SQL based on the
    ImageID,
    something like this:
    <%
    Dim rsImage__MMColParam
    rsImage__MMColParam = "1"
    If (Request.QueryString("ID") <> "") Then
    rsImage__MMColParam = Request.QueryString("ID")
    End If
    %>
    <%
    Dim rsImage
    Dim rsImage_cmd
    Dim rsImage_numRows
    Set rsImage_cmd = Server.CreateObject ("ADODB.Command")
    rsImage_cmd.ActiveConnection = MM_connImage_STRING
    rsImage_cmd.CommandText = "SELECT * FROM tblImages WHERE
    ImageID = ?"
    rsImage_cmd.Prepared = true
    rsImage_cmd.Parameters.Append
    rsImage_cmd.CreateParameter("param1", 5,
    1, -1, rsImage__MMColParam) ' adDouble
    Set rsImage = rsImage_cmd.Execute
    rsImage_numRows = 0
    %>
    Ken Ford
    Adobe Community Expert - Dreamweaver
    Fordwebs, LLC
    http://www.fordwebs.com
    "leeweatherill" <[email protected]> wrote in
    message
    news:ft00gm$spm$[email protected]..
    > Help needed please. Sorry if the topic has already been
    discussed. I did a
    > search but it returned nothing.
    >
    > My problem.
    > I can display images on my website by choosing the
    datasource and the
    > image
    > path from by database. No issues here. What I want is to
    be able to open
    > up a
    > larger image by clicking on this image.
    >
    > I created another page. On this page is an image
    placeholder. The source
    > again
    > is the datasource with the image path to a larger image.
    I used a
    > behaviour to
    > open this page however, it shows the same image (the 1st
    record in my
    > recordset) whichever image you click on my origianl
    page.
    >
    > Can someone please tell me how to do it? It would be
    appreciated.
    >

  • Display Images from  HTMLDB_APPLICATION_FILES Table?

    How do I display images from the HTMLDB_APPLICATION_FILES Table?
    Are the contents full available potentially for display? Or only after I have written them to another display?
    Please advise what I need to do or what corrections below is required:
    The calling procedure is a item in a SELECT statement as part of a report query:
    <P>
    <(img src="#OWNER#.download_HAF_file?p_file=  ' || nvl(ID,0) || ' height="50" width="50" )>, HAFimg<P>
    The Procedure is a adaptation of the Chapter 8 Exercise of the 2 day developer guide:
    CREATE OR REPLACE PROCEDURE "DOWNLOAD_HAF_FILE" (p_file IN NUMBER) AS
         v_mime VARCHAR2(48);
         v_length NUMBER;
         v_file_name VARCHAR2(2000);
         Lob_loc BLOB;
    BEGIN
         SELECT MIME_TYPE, BLOB_CONTENT, NAME, DBMS_LOB.GETLENGTH(BLOB_CONTENT)
         INTO v_mime, lob_loc, v_file_name, v_length
         FROM HTMLDB_APPLICATION_FILES
         WHERE ID = p_file;
         -- set up HTTP header
         -- use an NVL around the mime type and
         -- if it is a null set it to application/octect
         -- application/octect may launch a download window from windows
         owa_util.mime_header( NVL(v_mime,'application/octet'), FALSE );
         -- set the size so the browser knows how much to download
         htp.p('Content-length: ' || v_length);
         -- the filename will be used by the browser if the users does a save as
         htp.p('Content-Disposition: attachment; filename="'||SUBSTR(v_file_name,INSTR(v_file_name,'/')+1)|| '"');
         -- close the headers
         owa_util.http_header_close;
         -- download the BLOB
         wpg_docload.download_file( Lob_loc );
    END Download_HAF_File;
    /Message was edited by:
    luddite1812

    I believe you put HTML "pre" tags around your quote (with square brackets, I can't type them here because they'll be escaped).
    If the example below looks formatted then using "pre" works, if not...then ignore me ;)
    begin
      select
        count(*)
      into
        v_count
      from big_table;
    end;

  • Display Images stored on filesystem

    Hello,
    I have stored photos (JPEG images) in my OS filesystem and trying to create album to view them using BFILE datatype and stored procedure. I would like to diaply one photo on each page withlinks to next and previous photos. I was able to make this working but have still following issues.
    - It only shows image for first row. For other rows, the strored procedure doesn't even run.
    - The 'Layout and pagination' for report displays more rows on each page, even if I specify "Number of Rows" as 1.
    Could you help me fix these issues? Also, if you have better way to do it, I am willing to try.
    Thanks.
    Following are more details of my setup.
    Using Oracle Application Express 3.1.1.00.09 with Oracle 11g on RedHat server.
    Table description:
    SQL> desc swiss_photos
    Name Null? Type
    PHOTO_ID NOT NULL NUMBER
    PHOTO BINARY FILE LOB
    FILENAME VARCHAR2(255)
    MIMETYPE VARCHAR2(255)
    UPDATE_DATE DATE
    DESCRIPTION VARCHAR2(400)
    Sample data in table:
    SQL> select photo_id, photo, filename from swiss_photos
    PHOTO_ID PHOTO FILENAME
    3 bfilename('PHOTO_DIR', '2008-0 2008-05-16/img_2101.jpg
    5-16/img_2101.jpg')
    2 bfilename('PHOTO_DIR', '2008_0 2008_05_16/img_2100.jpg
    5_16/img_2100.jpg')
    Proceduer to display image:
    SQL> select text from user_source where name='DISPLAY_EASY_IMAGE' order by line;
    TEXT
    procedure display_easy_image( p_id number ) as
    s_mime_type varchar2(48);
    n_length number;
    s_filename varchar2(400);
    bfile_loc bfile;
    begin
    s_mime_type := 'image/jpeg';
    --INSERT code to verify if procedure gets executed
    insert into test_dei values (p_id);
    commit;
    select mimetype, dbms_lob.getlength(photo), filename, photo
    into s_mime_type, n_length, s_filename, bfile_loc
    from swiss_photos
    where photo_id = p_id;
    owa_util.mime_header(nvl(s_mime_type,'application/octet'), FALSE );
    htp.p( 'Content-length: ' || n_length );
    htp.p( 'Content-Disposition: filename="' || s_filename || '"' );
    owa_util.http_header_close;
    wpg_docload.download_file(bfile_loc);
    end display_easy_image;
    HTML expression of "PHOTO_ID" column for report:
    <img src="#OWNER#.display_easy_image?p_id=#PHOTO_ID#" width="700" height="700" />

    Hello,
    I have stored photos (JPEG images) in my OS filesystem and trying to create album to view them using BFILE datatype and stored procedure. I would like to diaply one photo on each page withlinks to next and previous photos. I was able to make this working but have still following issues.
    - It only shows image for first row. For other rows, the strored procedure doesn't even run.
    - The 'Layout and pagination' for report displays more rows on each page, even if I specify "Number of Rows" as 1.
    Could you help me fix these issues? Also, if you have better way to do it, I am willing to try.
    Thanks.
    Following are more details of my setup.
    Using Oracle Application Express 3.1.1.00.09 with Oracle 11g on RedHat server.
    Table description:
    SQL> desc swiss_photos
    Name Null? Type
    PHOTO_ID NOT NULL NUMBER
    PHOTO BINARY FILE LOB
    FILENAME VARCHAR2(255)
    MIMETYPE VARCHAR2(255)
    UPDATE_DATE DATE
    DESCRIPTION VARCHAR2(400)
    Sample data in table:
    SQL> select photo_id, photo, filename from swiss_photos
    PHOTO_ID PHOTO FILENAME
    3 bfilename('PHOTO_DIR', '2008-0 2008-05-16/img_2101.jpg
    5-16/img_2101.jpg')
    2 bfilename('PHOTO_DIR', '2008_0 2008_05_16/img_2100.jpg
    5_16/img_2100.jpg')
    Proceduer to display image:
    SQL> select text from user_source where name='DISPLAY_EASY_IMAGE' order by line;
    TEXT
    procedure display_easy_image( p_id number ) as
    s_mime_type varchar2(48);
    n_length number;
    s_filename varchar2(400);
    bfile_loc bfile;
    begin
    s_mime_type := 'image/jpeg';
    --INSERT code to verify if procedure gets executed
    insert into test_dei values (p_id);
    commit;
    select mimetype, dbms_lob.getlength(photo), filename, photo
    into s_mime_type, n_length, s_filename, bfile_loc
    from swiss_photos
    where photo_id = p_id;
    owa_util.mime_header(nvl(s_mime_type,'application/octet'), FALSE );
    htp.p( 'Content-length: ' || n_length );
    htp.p( 'Content-Disposition: filename="' || s_filename || '"' );
    owa_util.http_header_close;
    wpg_docload.download_file(bfile_loc);
    end display_easy_image;
    HTML expression of "PHOTO_ID" column for report:
    <img src="#OWNER#.display_easy_image?p_id=#PHOTO_ID#" width="700" height="700" />

Maybe you are looking for