Displaying Image Problem

Hello,
I need some advice. I have an existing java application that I am trying to convert into a portlet.
The application is a directory search of people on campus. The only catch is that
I am displaying their photo that is stored on a windows shared drive and I obtained
the path to the image from a database query. So, all of my functions to load and resize
the image are working, it is a matter of integrating everything into a portlet.
This is where I am stumped:
In my doView() method I have this snippet
//imagePath is a path that was found through a database query using a first and Last Name
String imagePath = getImageTag(Last_Name,First_Name);
session.setAttribute("imagePath", imagePath, PortletSession.PORTLET_SCOPE);
res.setContentType("text/html");
Writer writer = res.getWriter();
writer.write("<IMG SRC=" + res.encodeURL(req.getContextPath()+"/WEB-INF/jsp/image.jsp?file=" + imagePath) + ">");I had tried the <img src> line with a static image and it works, but integrating it using a jsp file has been a challenge.
This is what image.jsp looks like:
<%@ page import = "java.io.*" %>
<%
    //get fileName of image from request
    String imgFileName = request.getParameter("file");
    try {
       //get thumbnail of image in byte array format
       byte[] imgData = beans.ImageUtil.getImage(imgFileName) ; 
       response.setContentType("image/jpg");
       out.clear();     
       OutputStream o = response.getOutputStream();
       o.write(imgData);
       o.flush();
       o.close();
    catch (Exception e) {
      e.printStackTrace();
%>The getImage() method works fine in the standalone(non-portlet) application
so I know the code works fine otherwise. It seems like it is a matter of
putting everything together and getting it connected correctly in a
portlet. I am wondering if in image.jsp can't find the method getImage().
Any suggestions?
Perhaps, someone has an idea on bypassing the whole image.jsp idea.
Thanks,
Laura

Looks like you want to access the resource via direct URL. For IMG tag, the browser makes the direct request to the specified image source which is a jsp in your case. But WEB-INF cannot be accessed directly. So instead of "/WEB-INF/jsp/image.jsp" use "image.jsp". i.e image.jsp should not be inside the WEB-INF, put it outside of WEB-INF.

Similar Messages

  • Air display Image problem

    I fetch an api service from a remote site, get a xml result,
    the format is below:
    <?xml version="1.0" encoding="UTF-8"?>
    <rss version="2.0">
    <channel>
    <item>
    <title>ssss....</title>
    <description><![CDATA[ssss....]]></description>
    <pubDate>Thu, 29 Jan 2009 05:38:39
    +0000</pubDate>
    <guid>
    http://fanfou.com/statuses/xxx</guid>
    <link>
    http://fanfou.com/statuses/xxx</link>
    </item>
    <item>
    <title>ttt....</title>
    <description><![CDATA[ttt....]]></description>
    <pubDate>Thu, 29 Jan 2009 05:36:09
    +0000</pubDate>
    <guid>
    http://fanfou.com/statuses/yyy</guid>
    <link>
    http://fanfou.com/statuses/yyy</link>
    </item>
    </channel>
    </rss>
    i will compute image url from this xml item and then i put
    the ArrayCollection in the the Repeater' DataProvider , as below:
    <mx:Image
    source="{getUsrImage(getUsr(String(rep.currentItem.title)))}"/>
    ## this image could display
    <mx:Repeater id="rep" horizontalCenter="true"
    verticalCenter="true" width="100%">
    <mx:HBox width="100%" horizontalAlign="center">
    <mx:Label
    text="{getUsr(String(rep.currentItem.title))}"/> ## this image
    could display
    <mx:Image
    source="{getUsrImage(getUsr(String(rep.currentItem.title)))}"/>
    ## this image could NOT display
    </mx:HBox>
    </mx:Repeater>
    Stange thing happened:
    if I run that in Flex Builder enviroment, all Image and Label
    could be displayed, but If i deploy to air and install it on
    windows or mac machine, only the label inside the repeater can
    display, also the image outside the repeater can display, but the
    Image control inside the Repeater can not display. it seems that
    any dynamic generate expression in source or tip property will
    cause the control not function.
    can anyone explains this to me, it puzzle me for a long
    time.

    I am also having an issue that is fine when testing in Flash
    but stops working when compiled and installed as an AIR app.
    This saves an image to the desktop..... but does nothing in
    AIR.
    public function Main():void
    var bitmapData:BitmapData = new BitmapData
    (stage.stageWidth, stage.stageHeight, true, 0x000000 );
    bitmapData.draw(this);
    var jpgEncoder:JPGEncoder = new JPGEncoder( 100 );
    var byteArray:ByteArray = jpgEncoder.encode( bitmapData );
    var filename:String = "IMAGE.jpg";
    var file:File = File.desktopDirectory.resolvePath( filename
    var wr:File = new File( file.nativePath );
    var stream:FileStream = new FileStream();
    stream.open( wr , FileMode.WRITE);
    stream.writeBytes ( byteArray, 0, byteArray.length );
    stream.close();
    }

  • Problem Displaying image from blob

    Hi all,
    I m using,
    Database : 10g Rel 2
    Frontend : DevSuite 10g
    OS : WinXp
    Browser : IE 6
    Problem : In my forms i m displaying images from blob column but some of the images are not displayed. I have tried with all image formats available in combination with all available display quality but no luck. What could be the reason for it and how do i solve it?
    Can anyone help me plz?
    Thnx in advance.
    Imtiaz

    Hello,
    It is very difficult for us to "guess" what images you can read and what others you cannot.
    Maybe you could provide more information on images that are not displayed ?
    What is their native format ?
    Francois

  • Problem in displaying images one by one in JList

    I have a problem in displaying images one by one in Jlist. I want to show 100 images as a thumbnailview in jlist but it is talking too much time to show all the images after scalling 100 images to thumbnail view and making it into ImageIcon. So, i thought that it would be better way to show one by one after scaling it into thumnailview. But my renderer is getting calling after 100 images scaled down and setting into list. I have posted my code 2 days back but there is no reply.
    http://forum.java.sun.com/thread.jspa?threadID=789943
    I donno where i am missing in this code.
    Plz suggest me some solution for it.

    Where is the scaling done? In the ListCellRenderer? Regardless of where that is being done, I assume you are caching the scaled images after you scale them, right? If not, consider adding some sort of caching.
    This should do the trick...
    Rework your ListCellRenderer to check to see if a scaled version of the image is available. If not, start a thread to do the scaling and create an ImageIcon. In the meantime, while that thread is running, have the renderer return some sort of stock icon, like a little generic image icon. When the scaling thread completes, make a call to repaint() on the JList so the cell renderer gets re-asked for the icons. This time around, the renderer should notice that a scaled version (the ImageIcon) is available. Return that. So, this method doesn't guarantee that the images will be produced in order, 1...2...3..., but it will return images as they become available, and the overall JList rendering won't wait until all 100 are ready. If you want them returned in order, just do all of the scaling in a single thread and queue up the images to be scaled, in order.
    I hoped this helps. (If it does, please throw me some Duke Dollars.)

  • 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

  • Problem in displaying images stored in Blob variable

    Hi all,
    I have a requirement where i need to retrieve the image stored in Blob variable in DB and display the image in JSP page.
    I have written the below code to achieve this, it works fine
    In JSP, I am calling a action in the <img tag
    <img src='downloadPhoto.page?method=getPhotoInBytes&accessoryModelPictures.id.accessoryNumber=${photo.id.accessoryNumber}/> In my controller class
    InputStream inputStream=accessoryPicturesLOB.getPicture().getBinaryStream();
    byte[] theBytes = new byte[inputStream.available()];
    inputStream.read(theBytes);
    response.setContentType("image/jpg");
    response.getOutputStream().write(theBytes);But the problem is, *if i right click on the image and select save picture as option i get a error saying "The system cannot find the specified file "*
    Can you please tell me what is wrong in my approach/code
    Is there any better approach to display image that is store in Blob variable ?
    Please help on this.
    Thanks in advance.

    You need at least to set the filename in the content disposition header.

  • Problem with displaying image

    Hello!
    Sorry, I'm a beginner in APEX and have some problems with displaying images in my application. I have read the same topic but unfortunately didnt find the solution.
    So.. I have the interactive report
    table test (
    NAME NOT NULL VARCHAR2(4000)
    ID NUMBER
    BLOB_CONTENT BLOB
    MIME_TYPE VARCHAR2(4000))
    I need to display the column blob_content.
    Thnks a lot.

    1009316 wrote:
    Hello! Welcome to the forum: please read the FAQ and forum sticky threads (if you haven't done so already), and update your forum profile with a real handle instead of "1009316".
    When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s) (making particular distinction as to whether a "report" is a standard report, an interactive report, or in fact an "updateable report" (i.e. a tabular form)
    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.
    Sorry, I'm a beginner in APEX and have some problems with displaying images in my application. I have read the same topic but unfortunately didnt find the solution.
    So.. I have the interactive report
    table test (
    NAME NOT NULL VARCHAR2(4000)
    ID NUMBER
    BLOB_CONTENT BLOB
    MIME_TYPE VARCHAR2(4000))
    I need to display the column blob_content.This is described in the documentation: About BLOB Support in Forms and Reports and Display Image. There's an OBE tutorial that followed the introduction of declarative BLOB support in 3.1 as well.

  • Problem in bbm display image

    When I change bbm display image,it is not clear,its always blurr and dull it's not original image,might be there is some problem in bbm.
    Pls guide

    Hi punitinani,
    Are you changing your BBM display picture to a photo that you took with your device?
    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 Displaying Images in a JFrame

    I am writing a program that displays images on a JFrame window. I have been reading the other postings about this topic however I have not been able to make my code work. I am hoping there is some obvious solution that I am not noticing. Please help, I am very confused!
    public class WelcomeWindow {
    private JLabel label;
    private ImageIcon logo;
    public WelcomeWindow() {
    label = new JLabel();
    logo = new ImageIcon("/images/logo.gif");
    label.setIcon(logo);
    this.getContentPane().add(label);

    Instead of a JLabel, have you tried to use a JButton containing the Icon?
    Also (but I think you've done it already), you could do that :
    File iconFile = new File("/images/logo.gif");
    if (!iconFile.isFile()) {
    System.out.println("Not a file");
    That way you'll be certain that the path given is correct.
    Hope this helps.

  • Problem for displaying image in jsp

    I like to retrieve and display image from database in jsp file. Now, image has been retrieved and store in session. But it cannot be displayed in jsp. Who can help me? Thanks a lot!
    Codes like below:
    <%
    byte[] b = (byte[])session.getAttribute("sessionName");
    System.out.println(b.length); //the length can be printed at console successfully
    if(b != null) {
    response.setContentType("image/*");
    OutputStream toClient=response.getOutputStream();
    toClient.write(b);
    toClient.flush();
    toClient.close();
    %>

    JSP is designed to return text/html documents.
    As such it automatically calls getWriter() to return a character stream. (places it in the implicit variable "out"
    Seeing as you want to return bytes, instead of character data, the JSP technology is not applicable
    Calling getOutputStream after getWriter has been called results in an IllegalStateException
    So calling getOutputStream in a JSP will ALWAYS throw an exception.
    Cheers,
    evnafets

  • Display image in full screen

    Hi everyone, I am a newbie for labview. I just wanna ask you about image display in labview. Now I can display one image in my front panel. I open the file path and display it. First thing I wanna do is that is it possible to display on monitor full screen not on front panel and second thing is that how can I display images in folder and display it about 2 seconds delay in between? Pls kindly help me.
    Thanks millions.
    Solved!
    Go to Solution.

    Hi there, 
    -I don't know whether the image full display can be possible or not, Any reason why you are asking for such requirement?
    -The other question about reading files in a folder and display for 2sec can be done like shown in image.
    -I've attached vi in lv 12 if needed.
    -Next time, please post your vision related queries in Machine vision Board.
    Thanks
    uday,
    Please Mark the solution as accepted if your problem is solved and help author by clicking on kudoes
    Certified LabVIEW Associate Developer (CLAD) Using LV13
    Attachments:
    Image_read_folder.vi ‏43 KB

  • Display image in detail groups in jheadstart 11.1.1.3.35

    Hi, I've been trying to make a project that should display one picture in one of the detail groups. but when i generate the jheadstart definition editor and run the project, it shows an empty box for the image (image is not loaded).
    I've seen the source code and every thing seems right and when i use that detail group as a master group the image display just fine.
    is jheadstart 11g have a problem for displaying image in detail groups? because I've heard this option works in 10g pretty fine.
    please help me how i can fix this problem and i have to say my project deadline is coming :(

    We are not aware of such a problem.
    To really check whether it is related to a detail group, can you temporarily make the detail group a top-level group, generate and run your application to see whether the problem goes away?
    Make sure you first uncheck the Same Page checkbox before you drag and drop the detail group to become a top group.
    There is a known ADF issue that when you upload a new image, the new image is only shown when you restart the session.
    Steven Davelaar,
    JHeadstart Team.

  • Display image in view

    Hi,
    My requirement is to create a  web dynpro application where the first view contains all images stored in ECC along with one button (Display image). When the user clicks on the button Display image then another view should display the image on the screen.
    I have created View1 with a table,which display the details of the table STXBITMAPs in it,when i select a row and press a button second view is displayed with a UI conatiner of type IMAGE.
    Basiccaly when button on view1 is pressed, I get the value of the TDNAME field via lead_selection method and set this value to a global attribute, whch inturn is copied into second view and bonded to the SOURCE attribute of the UI element.
    My problem is , that global attribute is being updated probley and value have been passed to second view..but Image is not being displayed on the screen.
    Can anyone help me out in this.
    Thanks in advance.
    Pooja

    You don't necessarily have to move your images from STXBITMAPS to the MIME repository.  You can display any image - not just those in the MIME repository, by placing the content in the ICM Cache.  This creates a temporary URL for any content.  So you just need to read the binary content of the image from STXBITMAPS into a XSTRING variable.  From there you can use this code sample to put the content in the cache and generate a URL:
    ****Create the cached response object that we will insert our content into
      data: cached_response type ref to if_http_response.
      create object cached_response
        type
          cl_http_response
        exporting
          add_c_msg        = 1.
    *  cached_response->set_compression( options = cached_response->IF_HTTP_ENTITY~CO_COMPRESS_IN_ALL_CASES ).
    try. " ignore, if compression can not be switched on
          call method cached_response->set_compression
            exporting
              options = cached_response->co_compress_based_on_mime_type
            exceptions
              others  = 1.
        catch cx_root.
      endtry.
    ****set the data and the headers
      data: l_app_type type string.
      data: l_xstring type xstring.
          cached_response->set_data( me->gx_content ).
          l_app_type = 'image/x-ms-bmp'.
      cached_response->set_header_field( name  = if_http_header_fields=>content_type
                                         value = l_app_type ).
    ****Set the Response Status
      cached_response->set_status( code = 200 reason = 'OK' ).
    ****Set the Cache Timeout - 60 seconds - we only need this in the cache
    ****long enough to build the page and allow the IFrame on the Client to request it.
      cached_response->server_cache_expire_rel( expires_rel = i_cache_timeout ).
    ****Create a unique URL for the object
      data: guid type guid_32.
      call function 'GUID_CREATE'
        importing
          ev_guid_32 = guid.
      concatenate i_path '/' guid '.' i_format into r_url.
    ****Cache the URL
      cl_http_server=>server_cache_upload( url      = r_url
                                           response = cached_response ).

  • Upload and display image in webside

    Hello Friends,
    I am developing an auction web site ,and facing some problem so I need your help.
    There is some confusion about uploading and displaying images in website .In web based
    application if I want to upload images than where have to store the images database or server
    side any folder .I have not idea about that please send your ideas and sussesions.
    Second problem is What is the best way to display images in webside either giving a direct
    path of server side image folder or I need to retrieve all images from database .
    I have no idea about it please send me your guideline which are usefull for me to implement in my
    website.
    what is the correct way to upload and display images in website ?
    Thanks . Have a nice day.

    If you are using a Container you just leave your image files in the home directory of your web application. And forget this idea about database. It´s not necessary in this case.
    To display the images just use HTML, <img src="url">.

  • Report - Not able to display image stored on External server or internet

    Hi
    I need to display image on report that is on different instance for that i had put a formula column (in report 10g) and for that coloum i made file format as image and read from file as Yes and giving it the URL of Image stored on different server . but at run time for PDF output i am getting error like REP-1295: Data format of column 'CF_1' is unsupported
    Please help me , Thx in advance.
    Ranga

    Hi,
    I've got the same problem.
    Did you find any solution?
    Thank you
    Davide

Maybe you are looking for

  • IPad IOS 4.2 Update Issues (Help)

    My 2010 Macbook pro's hard drive died on me last week. I have a new HD on the way and plan to restore via Time backups. No biggie. I have a Windows XP laptop that I use for work. In order to update my iPad to the new IOS 4.2, (while I wait for my Mac

  • Goods Reciept--urgent

    Hi everyone, we have a scenario where i have raised an Import PO, but cannot recieve the materials into factory store due to financial problems & store problem. So the material will be in bonded warehouse in customs place I have reciept the goods wit

  • Can't update software because connections???

    I have read several discussions on how to update my iphone without the software button. However when I am in itunes it tells me it can't check for updates because of iphone server could not be reached. Check my connections & try again?? I'm using the

  • [SOLVED] Broadcom bcm4318 cannot connect anymore

    Hello, I'm using arch on a HP Compaq nc6120 laptop with a Broadcom bcm4318 wifi chip. So far it worked correctly with the b43 driver. Now I have the biggest difficulties to connect to any ssid using NetworkManager, although surprisingly it happens to

  • IPhone 3gs suddenly doesn't work as modem??

    Hello I suddenly can not get online on my MBP with Leopard via a bluetooth connection to my iPhone 3gs. There is connection between iPhone and computer and the iPhone works as it should, internet sharing is enabled on the phone but the computer says