Problem displaying picture stored in mySQL

Hi, i just have got problem displaying picture stored in database as BLOB and presented on JSP over servlet. Below is my code i am using to upload file into database, than download it and display again. The result is the picture can not draw inself and there is always only empty picture space on the web page i am displaying. Please help me to find why it is not working, thanx.
servlet uploading picture to database
               boolean isMultipart = FileUpload.isMultipartContent(req);
               DiskFileUpload upload = new DiskFileUpload();
               List items = upload.parseRequest(req);
               Hashtable textFields = new Hashtable();
               byte[] data = new byte[4096];
               if(isMultipart)
                    Iterator iter = items.iterator();
                    while(iter.hasNext())
                         FileItem item = (FileItem)iter.next();
                         if(item.isFormField())
                              textFields.put(item.getFieldName(), item.getString());
                         }else{
                              data = item.get();
               String sqlStatement = "INSERT INTO cds VALUES('" textFields.get("id")"'," +
                                        "'" textFields.get("album") "','" textFields.get("interpreter") "'," +
                                                  "'" textFields.get("gr1") "','" textFields.get("gr2") "','" textFields.get("price") "')";
               String sqlStatement2 = "INSERT INTO pics VALUES('" textFields.get("id") "','" data "')";
servlet to download picture
String SQL =
     "SELECT Picture " +
     "FROM pics " +
     "WHERE id = '" + request.getParameter("id") + "'";
     ResultSet rs = stmt.executeQuery(SQL);
     rs.next();
     Blob blob = null;
     blob = rs.getBlob(1);
     response.setContentType("image/jpg");
     request.setAttribute("blob", blob);
     System.out.println("just above OutputStream");
     InputStream in = blob.getBinaryStream();
     ServletOutputStream sout = response.getOutputStream();
     int b;
     while ((b = in.read()) != -1) {
     sout.write(b);
     in.close();
     sout.flush();
     sout.close();
img tag in JSP
<img src="LoadImageServlet?id=some id>
plus i am using
Tomcat 5.0
mySQL 4.0
debuging in eclipse
thanx for help once more, Libor.

1:
are there any exceptions throws by the jdbc code
2:
is the code in a doGet
3:
you should do a if(result.next())
4:
Is your mapping code working

Similar Messages

  • N82, Gallery doesn't display pictures stored in th...

    Hi!
    Suddenly the gallery function doesn't display pictures stored on the memorycard. Well, not any files in the memory card.., doesn't recognize musicfiles either.
    Is there a way to set the gallery function to display files in the memory card? It did automatically before.
    New pictures are stored in the memorycard and also not displayed.
    I can browse and open the pictures using the filemanager. If i copy them to the phonememory it also displays correctly..
    I've upgraded the firmware but the problem remains..
    Help much appreciated
    Solved!
    Go to Solution.

    glad its worked
    If you find my post useful then click on
    Kudos!Nokia N96 (v20.050 / RM-247)
    www.shaysoft.net | Competitions!

  • Problem displaying PDF stored in BLOB column

    Hello everyone.
    I've been trying to follow this tutorial http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::p11_question_id:232814159006 on displaying PDFs stored in BLOB columns. This is being performed on Apex 4.2, with my DB running 11g. I've got my procedure, which I'll post below:
    create or replace procedure "PDF" (p_id IN gvo_documents.doc_id%type)
    is
        l_lob    blob;
        l_amt    number default 30;
        l_off   number default 1;
        l_raw   raw(4096);
    begin
        select contents into l_lob
            from gvo_documents
             where doc_id = p_id;
    -- make sure to change this for your type!
        owa_util.mime_header( 'application/pdf' );
        begin
            loop
              dbms_lob.read( l_lob, l_amt, l_off, l_raw );
              htp.prn( utl_raw.cast_to_varchar2( l_raw ) );
              l_off := l_off+l_amt;
              l_amt := 4096;           
        end loop;
            exception
               when no_data_found then
                  NULL;
            end;
    end;
    I am trying to run this through a PL/SQL dynamic region and while I don't receive any error's, the content displayed is a huge mess of garbled text and odd characters. I've tried to run this procedure on numerous other document types, including word files and jpeg images, all with the necessary changes in my procedure, and regardless of what I use, I still get a large mess of strange characters. Does anyone have any information or ideas about why this is happening?

    If I understand correctly, your requirements needs to be broken down into two problems:
    1) click link that pops up a window displaying a new APEX page
    2) an APEX page the displays the document, not downloads it.
    I haven't done #1 (yet).
    However, you may be able to generate a URL that points to the new page as part of the SELECT statement for the Report.
    This has a related question, but no answer yet:
    open pdf in popup browser window
    The key is target="_blank" for the anchor tag.
    To generate the URL, you should use the APEX_UTIL.prepare_URL() function.
    If that doesn't work, a Dynamic Action that does some magical JavaScript stuff may be needed.
    For #2, I lost the URL that showed how to display a PDF as part of a "form" page.
    From what I remember:
    Start with a blank page with one blank HTML region (all the Items go in the HTML region)
    Add an Item for the PK/Doc_ID
    part I forgot Create a Data Manipulation Process
    - Automated Row Fetch
    - On Load - After Header
    - (stuff for your table/view)
    part I forgot Create an (I believe) "File Browser" item type. For Settings:
    - Storage Type "BLOB column specified in Item Source" (and place the column name of the BLOB there)
    - MIME Type Column: (column name) -- since you have multiple types, this is a MUST HAVE
    - Filename Column: (column name) -- I highly recommend you have this.
    - Content Disposition == INLINE <-- this is the kicker
    Also, you will need a Browser Plugin for each of the MIME Types (otherwise, the browser may try to 'download' the file)
    Browsers can handle Image types internally. Adobe's plugin can handle PDFs. I don't know about Word/Excel.
    Again, I don't remember the exact details, but that should cover most of it.
    MK

  • Problems displaying images stored in SQL Server as Datatype "image"

    I am trying to display an Image stored in SQL Server as
    datatype
    'image' and it only shows a portion of the image.
    It seems to be tied to the size (kb) of the image since the
    larger the
    image the less of it is shown before it cuts off(sometimes it
    cuts off
    mid line so it's about the file size and not fitting the
    image on the
    screen).
    Here is the code I am using that deals with the image.
    [Bindable]
    public var theImage:ByteArray = new ByteArray;
    private function getScans_result(event:ResultEvent):void{
    var imageByteArray:ByteArray = event.result[0].Image;
    theImage = imageByteArray
    <mx:Image id="theIMG" width="160" height="220"
    source="{theImage}"/>
    Any Thoughts??

    I do that sort of thing using PHP and mySQL the binary part
    of the image is stored in a BLOB field (Binary Large OBject) along
    the rest of the information necessary for the http headers (e.g.
    mime type, file name, file size) being staored in their own fields.
    That info is then used to build the file using PHP. The PHP
    file contains a mySQL query whos result is echoed with the
    appropriate headers. The URL points at the PHP file rather than at
    any saved image.
    Here's the php:
    <?
    # display_imagebank_file.php
    # Note: the ID is passed through the url e.g.
    # this_files_name.php?id=1
    # connect to mysql database
    mysql_connect('HOST', 'USERNAME', 'PASSWORD');
    mysql_select_db('DATABASE');
    # run a query to get the file information
    $query = mysql_query("SELECT FileName, MimeType, FileSize,
    FileContents FROM blobTable WHERE ID='$id'");
    # perform an error check
    if(mysql_num_rows($query)==1){
    $fileName = mysql_result($query,0,0);
    $fileType = mysql_result($query,0,1);
    $fileSize = mysql_result($query,0,2);
    $fileContents = mysql_result($query,0,3);
    header("Content-type: $fileType");
    header("Content-length: $fileSize");
    header("Content-Disposition: inline; filename=$fileName");
    header("Content-Description: from imagebank");
    header("Connection: close");
    echo $fileContents;
    }else{
    $numRows = mysql_num_rows($query);
    echo "File not found <br>";
    echo $numRows;
    echo " is the number of rows returned for id = ";
    echo $ID;
    ?>
    Hope that helps
    Phil

  • Problem displaying pictures in some sites, sites do not complete loading

    Hi,
    I'm experiencing a problem which I think is not from Safari, because it happens in FireFox also. Pictures in some sites most of the time do not display (sites like YouTube and Qik.com). These sites do not completely load.
    I consulted a friend of mine (remotely) who is a network administrator, but he didn't find anything wrong with the router or net setup.
    This problem didn't exist earlier this year. I switched to 10.5.5 lately copying settings from a backUp of my 10.4.
    Any ideas would be greatly appreciated.

    I have the problem using Firefox 8.0.1.
    Particularly when loading any '''https:// '''websites and control panels.
    This occurs in XP Pro SP3 / Windows Vista Ultimate / and Windows 7 Ultimate.
    This did not occur in Firefox 8.0

  • How to display and save a picture stored as BLOB in MySQL database in Jsp?

    Hello i am doing a dataentry form where in i will display the picture stored as Blob in MySQL database to the browser. The form also allow changing the picture and updating the picture Blob in the database.
    How can i do it? I try this
    <img src'"<%=rs.getBlob("picture")%> but it doesn't display the picture.
    another thing, how can i save it in the database, if is use the file field in the html form?
    thanks in advance for your help.

    Hello i am doing a dataentry form where in i will display the picture stored as Blob in MySQL database to the browser. The form also allow changing the picture and updating the picture Blob in the database.
    How can i do it? I try this
    <img src'"<%=rs.getBlob("picture")%> but it doesn't display the picture.
    another thing, how can i save it in the database, if is use the file field in the html form?
    thanks in advance for your help.

  • Forms 6i - display into image item picture stored in blob type on database

    hi to all
    i searched on this forum but in don't found solution my problem.
    I created table with a column blob and i design form that insert and display image stored in database ( oracle 9i )
    i used image item type with block database based
    my version forms is
    Forms [32 Bit] Version 6.0.8.13.0 (Production)
    if i define column table like "long raw" it worked but i used blob i insert but i don't display image
    error is:
    ORA-00932: inconsistent datatypes: expected got
    thanks a lot to all
    bye

    I know, that the false forms-version (patch) gives you this errors. Try a newer patchset. For example patch 13-15 (for 9i), or 17 (10g rel. 1)

  • Display picture problem since 4 days

    I have problem in my display picture. My old picture doesn't change from 4 days , I tried to do everything I can but no good result so what I have to do?  Please advise me.

    Hi Shaikha707 and welcome to the BlackBerry Support Community Forums!
    To better assist, which display picture is not changing for you?
    Thanks.
    -CptS
    Come follow your BlackBerry Technical Team on twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.Click Solution? for posts that have solved your issue(s)!

  • Problem with displaying picture.

    I use PS-CC and LR5.on a HP i7 computer and windows 7.Camera D-800, pictures in raw.
    I usually import pictures in nef  in LR5,. After  some corrections, I export my pictures to DNG format. I sometimes do a little bit of work in camera raw then go into Photoshop.
    My problem: When in photoshop, I get a grainy version of my photo which wasn't the situation in LR5 or Camera raw, Hard to work with. The grains will disappear when I enlarge the picture but then I have to enlarge it so much that I only see or can work with only part of my picture. The problem does not appear in CS6.
    Hope somebody can help me.
    Thanks
    Jacques Legault

    I should clarify this.. When I import photos into LR5, I always use copy as
    DNG. I know that NEF and DNG are the same for photoshop and I always shoot
    in raw.
    One thing I do not know is how to do a screen shot. I will get back tro you
    on that. When I say grain, or noise if you like, I mean that, if i relate
    to films, my picture in LR5  would be at ISO 100 and my screen shot in
    photoshop would look like it was boosted to 1200 or worse.
    See you soon I hope with a screen shot.
    2014-06-14 13:43 GMT-04:00 twenty_one <[email protected]>:
        Problem with displaying picture.  created by twenty_one
    <https://forums.adobe.com/people/twenty_one> in *Photoshop General
    Discussion* - View the full discussion
    <https://forums.adobe.com/message/6458682#6458682>

  • I can no longer shoot directly into phaseone software since i use my new macbook pro with retina display. pictures are not transfered from the camera into captureone. anyone else with this problem? any solutions?

    i can no longer shoot directly into phaseone software - neihter version 6 or 7 - since i use my new macbook pro with retina display. pictures are not transfered from the camera into captureone. anyone else with this problem? any solutions?

    My eyes just glazed over...Please in the future break down each of your issues with paragraphs separated by two carriage returns. It would be much easier when trying to address your issues.
    Go to Apple menu -> System Preferences -> Keyboard and Mouse -> Mouse
    And edit your mouse settings to do what you want it to do.
    Secondly, this is not the place to vent. If you have a complaint, there is:
    http://www.apple.com/feedback/
    or http://www.apple.com/contact/
    We are just end users here helping other end users.
    Third, from my understanding, it would appear you are concerned about the noise the hard drive makes when it falls asleep? Why not put your machine in screen saver mode instead? Apple menu -> System Preferences -> Energy Saver turn off all Energy Saver settings, or set them to run Never.
    Fourth, if your machine was purchased just a few days ago, you may still be able to get an exchange from the store, quicker than you can get a repair done. You may want to look into that possibility.
    Fifth, it does appear you found the Logic forum. I would persist in asking there how to solve your technical issue with Logic regarding the audio. It may be you don't have to do anything special to the hard drive. Remember audio can be transmitted by wire, avoiding ambient sounds.
    Good luck!

  • BBM 5 Display Picture changing problem

    Hi..
    OK here .. i guess it is a new problem with the new BBM ..
    whenever i change my display picture, it doesn't change with my contacts..
    i have added myself to test the problem, and it didn't change even though it changes on my BBM header..
    We need a fix
    thank you

    i have tried upgrading the OS of the blackberry, but the problem is still there.
    Let's hope it's gonna be fixed soon

  • Call Display Picture Always Full Screen (I don't want that)

    There are a few discussions about this, but they all seem to be over 4 years old, and I still have the problem.  (Please read the whole explanation, as I've tried several fixes already)
    I am extremelly picky with my computer and phone "stuff".  Ever since I've owned my iPhone I've made it a point to add a picture to every contact I have.
    Early in my iPhone ownership I realized that if you add a picture directly from your iPhone (wether is taking it directly from the iPhone cam while adding the contact or choosing from the library) such picture shows FULL screen when I call that person or when that person calls me.  If I simply open Address Book in my Mac and "drag" a picture (say for instance from Facebook) into the picture section of that contact and then synch, then when I make or receive a call from that person it shows small and I still see my wallpaper on the background.
    Well THAT's what I want (just like in the Appple commercials), I DON'T want the full screen picture.
    Now here's THE PROBLEM;
    For some reason NOW, I STILL add pictures the SAME WAY (I go into Facebook, and drag the picture into Address Book) but when I make or receive a call from that person the display picture ALWAYS shows full screen!!  It's annoying the heck out of me!!
    The ONLY thing different is that now my contact are synched thru iCloud as opposed to synching using a USB cable in iTunes, HOWEVER, SOME contacts show how they are supposed to show (even adding them thru iCloud), but MOST others don't! I feel I should add that ALL contacts I had BEFORE I strated synching with iCloud still show fine, the ones that have a problem are MOST (but not all) of the ones I added AFTER I started synching thru iCloud.  And the fact that a few worked fine leads me to believe there's got to be a way of making them all show small.
    Anyone has any idea of how to keep them ALL the same?

    OK, that's interesting.  Now, how do I get all of my contact photos into iPhoto? And do I have to do this one contact at a time, or is there a setting where I can "import all".  Furthermore, once all photos are in iPhoto and I select "Import Face from iPhoto" can I do such actions for all contacts at once or do I have to do them one at a time?

  • Problem displaying CLOB in text file

    Hello All,
    I have a problem displaying the content from the database in notepad. When I click on a link on my jsf screen, I retrieve the data and display it in notepad.
    I have my text content stored in the database with CLOB datatype. When I look in the database the data looks in the following format:
    ---------STARTS FROM NEXT LINE-------------
    The firm, known for its keen oversight of products, has been the subject of complaints from firms who have had apps blocked from the store. Some developers have complained that the company's rules seem inconsistent.
    Some have found apps blocked after seemingly minor updates, or for having content deemed inappropriate by them. In light of this, and after careful consideration, I believe it is unnecessary to sign this measure at this time.
    Sincerely,
    ABC
    ----------ENDS IN THE PREVIOUS LINE------------
    Now when I display this content onto the notepad, all the spaces and new line characters are lost, and the entire display looks awkward. This is how it looks:
    The firm, known for its keen oversight of products, has been the subject of complaints from firms who have had apps blocked from the store. Some developers have complained that the company's rules seem inconsistent.[]Some have found apps blocked after seemingly minor updates, or for having content deemed inappropriate by them. In light of this, and after careful consideration, I believe it is unnecessary to sign this measure at this time.[]Sincerely,[]ABC
    All the new line characters are lost and it just puts some junk character in place of a new line.
    When I copy the same text onto textpad, everything is alright and it displays exactly the way it is present in the database. I am also open to display the content in html, but in HTML it doesn't even display me the junk character in place of new line. It is just one single string without any line separators.
    I am using the following code to put the content into the text.
    public String writeMessage(){
       OutputStream outStream = null;
       HttpServletResponse response = getServletResponseFromFacesContext();
       Reader data = null;
       Writer writer = null;
       try{
          response.reset();
          response.setContentType("text/plain; charset=UTF-8");
          response.setHeader("Content-Disposition","attachment; filename="+id+"_Message.txt");
          outStream = response.getOutputStream();
          QueryRemote remote = serviceLocator.getQueriessEJB();
          data = remote.retrieveGovernorsVetoMessage(billId);
          writer = new BufferedWriter(new OutputStreamWriter( outStream, "UTF-8" ) );
          int charsRead;
          char[] cbuf = new char[1024];
          while ((charsRead = data.read(cbuf)) != -1) {
             System.out.println(charsRead);
          writer.write(cbuf, 0, charsRead);
          writer.flush();
       }catch(Exception ex){
          ex.printStackTrace();
       }finally{
          //Close outStream, data, writer
          facesContext.responseComplete();
       return null;
    }Any help or hints on resolving this issue would be highly appreciated.
    Thanks.

    The data is imported from a third party application to my database. It doesn't display any newline characters when I view the data.
    But when I do a regular expression search on text pad, I could see that my clob contains \n as the new line character. Is there a way to replace \n with \n\r while writing the data.
    Thanks.

  • Display picture in messages totally  pixelated when seeing it with yahoo messenger for windows

    Hello,
    I'm using messages to chat with my yahoo messenger account  at work and yahoo messenger for windows at home.
    When I log into Yahoo with messages, my yahoo display picture is updated automatically with the one I have choose in messages.
    My problem is that this picture is totally pixelated when you see it on yahoo messenger for windows. It seems that Messages is changing its size.
    As the size in Yahoo messenger for windows is bigger it appears pixelated!
    If I choose no display picture in messages, the one I have choose with yahoo messenger for windows disappear when I'm logging with it.
    Is there a way that messages do not update the display picture each time I'm logging to Yahoo?
    I suppose that there is no solution to this problem but I wanted to be sure.
    Anyway thanks for your help.

    HI,
    Thanks for the Path.
    This does seem to show all the Recents from the Contacts App > My Card, the Login Pic and the Messages Buddy List pic.
    I think in Mountain Lion these were either separate items  or the .plist that is in the current place listed the app/location the pic was used.
    I have looked at the pictures in the folder (.png and thumbnail .tiffs) and the .plist and it does seem to be all the pics I have used in all three places over the last few months.
    The Yahoo account is logged in not through IMAgent that FaceTime and Messages use for other Accounts but from the IMServicePluginAgent.
    In Mountain Lion this used to list a Buddy Pic server as well as a straightforward login.
    Using Little Snitch I am not seeing that in Mavericks.
    Seems you may have to change your Pic on a web page for your Yahoo account.
    Edit
    for the Points
    9:22 pm      Friday; November 8, 2013
      iMac 2.5Ghz 5i 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad
    Message was edited by: Ralph Johns (UK)

  • Please help!! Problem synching pictures from Laptop to iPhone4????

    Hey guys, I am new to this so I would really appreciate anyones help very much! I just bought a brand new iPhone4 and last year a brand new Toshiba laptop. I dont know a great deal about how Itunes works but I know the basics. I downloaded all my apps and everything using my iPhone and then when I plugged my phone into the laptop it synched all of my songs, photos, apps etc into folders in Itunes. Anyway, basically what i want to do is synch photos from my pictures folder and put them into my iphone however, when i go in to do so and select the folder to synch the message i recieve says "are u sure u want to remove 53 apps from your iPhone"?? and i really dont understand why? When i plug my phone in and click on the icon in itunes it brings up my phone and shows all the content that is currently on it but when i click on apps, all of my apps that are displayed (picture that shows your iphone) dissapear and they are all in the left hand box for me to drag over into the phone one by one? I dont want to remove them as i already have them how i like them into sorted folders and i really want to know how i can leave my apps how they are and stop this message saying do i want to remove my apps everytime i synch anything? I am not able to do any synching because of this as it will cause me to lose everything? I feel like it has something to do with when i clicked on transfer purchased items into itunes because before i did this all my apps didnt show up in the left hand column area for me to drag into my phone - but i dont know how to delete them from that area and keep my apps how they are - and just be able to synch anything else as i need to? I am sorry this is all over the place but i am finding it hard trying to explain what i mean but i am really really hoping someone might know what i can do to fix this.. I would appreciate anyones help very very much! Thanks heaps! : ) Jamo.
    Message was edited by: Jamo1987

    Did you get a dialog to convert the video first before copying? If yes, and you confirmed, encoding long videos could take ages on weak computer, so perhaps this is not an issue at all..
    The problem with this conversion is that not all formats are readable by default Movies app in the phone, so it asks you to convert it before the transfer "on-the-fly". This takes some time (long if it is some full movie). But if you use another player, like MXVideo for example, you don't really need to convert it, and the transfer will then go very fast (just copying).
    I thought it is the driver issue, because there is such problem too (Media Go acts more like a snail than a media manager, and it happens with PCC active simultaneously).
    When everything have failed already, try to read the manual.
    Kudos mean I am helpful. Am I for you? Then support me back

Maybe you are looking for