ClasscastException while displaying image from content selector

Hi,
My requirement is show an image gif file in jsp, through portal.
This problem is specific to 8.1 version.
Created an image type content in BEA repository which i could retrieve from workshop
content preview correctly, with a rule (named filerule).
However, when tried to display the same from a simple jsp logic, got classcast
exception.
Below is the steps i have done.
1. import <%@ page import="com.bea.p13n.content.ContentHelper"%>
2.
<pz:contentSelector rule="filerule" contentHome="<%=ContentHelper.DEF_DOCUMENT_MANAGER_HOME%>"
id="ImageDocs"/>
<es:forEachInArray array="<%=ImageDocs%>" id="anImageDoc" type="com.bea.p13n.content.Content">
<img src="ShowDoc/<cm:printProperty
id="anImageDoc" name="identifier" encode="url"/>"
</es:forEachInArray>
The server console shows below exception:
java.lang.ClassCastException
at jsp_servlet.__index6._jspService(index6.jsp:19)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:971)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:402)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
va:27)
at com.bea.p13n.servlets.PortalServletFilter.doFilter(PortalServletFilte
r.java:313)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
va:27)
at com.bea.wlw.netui.pageflow.PageFlowJspFilter.doFilter(PageFlowJspFilt
er.java:208)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
va:27)
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispat
cherImpl.java:305)
at com.bea.wlw.netui.pageflow.PageFlowRequestProcessor.superForward(Page
FlowRequestProcessor.java:1304)
at com.bea.wlw.netui.pageflow.PageFlowRequestProcessor$DefaultHttpRedire
ctor.forward(PageFlowRequestProcessor.java:1320)
at com.bea.wlw.netui.pageflow.PageFlowRequestProcessor.doForward(PageFlo
wRequestProcessor.java:1200)
at com.bea.wlw.netui.pageflow.PageFlowRequestProcessor.processForwardCon
fig(PageFlowRequestProcessor.java:1094)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:279)
at com.bea.wlw.netui.pageflow.PageFlowRequestProcessor.process(PageFlowR
equestProcessor.java:651)
at com.bea.wlw.netui.pageflow.AutoRegisterActionServlet.process(AutoRegi
sterActionServlet.java:527)
at com.bea.wlw.netui.pageflow.PageFlowActionServlet.process(PageFlowActi
onServlet.java:152)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:971)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:402)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
va:27)
at com.bea.p13n.servlets.PortalServletFilter.doFilter(PortalServletFilte
r.java:313)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
va:27)
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispat
cherImpl.java:305)
at com.bea.wlw.netui.pageflow.PageFlowRequestProcessor.superForward(Page
FlowRequestProcessor.java:1304)
at com.bea.wlw.netui.pageflow.PageFlowRequestProcessor$DefaultHttpRedire
ctor.forward(PageFlowRequestProcessor.java:1320)
at com.bea.wlw.netui.pageflow.PageFlowRequestProcessor.doForward(PageFlo
wRequestProcessor.java:1200)
at com.bea.wlw.netui.pageflow.PageFlowRequestProcessor.process(PageFlowR
equestProcessor.java:638)
at com.bea.wlw.netui.pageflow.AutoRegisterActionServlet.process(AutoRegi
sterActionServlet.java:527)
at com.bea.wlw.netui.pageflow.PageFlowActionServlet.process(PageFlowActi
onServlet.java:152)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:971)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:402)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
va:27)
at com.bea.p13n.servlets.PortalServletFilter.doFilter(PortalServletFilte
r.java:313)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
va:27)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:6356)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:
118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:3635)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2585)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
>
Also, there is no luck with displaying text content from a file, using printDoc
tag. Can some one point me to right resource.

Hi panji,
I used 7.0 tag lib, just to make use of "printDoc" tag which is available in 7.0version
only and not in 810. However, i figured out a way to display image using 8.1 (
of course, by using request.getContextPath() + "/ShowBinary" + imagedoc.getPath())
But still, i do not find a way to display a doc type file in jsp, which is my
original problem.
As per the edocs at http://edocs.bea.com/workshop/docs81/doc/en/core/index.html,
<cm:getProperty node="<%=doc_node%>" name="file"/>
should be able to display a txt file but nothing is getting rendred onto jsp.
( i have created a book type content in the repo. and file attached is of type
txt ).
Can you pls give some clue what i am missing here?
thanks
Ramana
"Panji Aryaputra" <[email protected]> wrote:
Hi Ramana, could you just use the ShowPropertyServlet to display the
image
in jsp? That's what I am using now. Perhaps you have other reasons not
to
use it?
panji.a
"ramana" <[email protected]> wrote in message
news:[email protected]...
Hi,
My requirement is show an image gif file in jsp, through portal.
This problem is specific to 8.1 version.
Created an image type content in BEA repository which i could retrievefrom workshop
content preview correctly, with a rule (named filerule).
However, when tried to display the same from a simple jsp logic, gotclasscast
exception.
Below is the steps i have done.
1. import <%@ page import="com.bea.p13n.content.ContentHelper"%>
2.
<pz:contentSelector rule="filerule"contentHome="<%=ContentHelper.DEF_DOCUMENT_MANAGER_HOME%>"
id="ImageDocs"/>
<es:forEachInArray array="<%=ImageDocs%>" id="anImageDoc"type="com.bea.p13n.content.Content">
<img src="ShowDoc/<cm:printProperty
id="anImageDoc" name="identifier" encode="url"/>"
</es:forEachInArray>
The server console shows below exception:
java.lang.ClassCastException
at jsp_servlet.__index6._jspService(index6.jsp:19)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
atweblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:971)
atweblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:402)
atweblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
atweblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
va:27)
atcom.bea.p13n.servlets.PortalServletFilter.doFilter(PortalServletFilte
r.java:313)
atweblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
va:27)
atcom.bea.wlw.netui.pageflow.PageFlowJspFilter.doFilter(PageFlowJspFilt
er.java:208)
atweblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
va:27)
atweblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispat
cherImpl.java:305)
atcom.bea.wlw.netui.pageflow.PageFlowRequestProcessor.superForward(Page
FlowRequestProcessor.java:1304)
atcom.bea.wlw.netui.pageflow.PageFlowRequestProcessor$DefaultHttpRedire
ctor.forward(PageFlowRequestProcessor.java:1320)
atcom.bea.wlw.netui.pageflow.PageFlowRequestProcessor.doForward(PageFlo
wRequestProcessor.java:1200)
atcom.bea.wlw.netui.pageflow.PageFlowRequestProcessor.processForwardCon
fig(PageFlowRequestProcessor.java:1094)
atorg.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:279)
atcom.bea.wlw.netui.pageflow.PageFlowRequestProcessor.process(PageFlowR
equestProcessor.java:651)
atcom.bea.wlw.netui.pageflow.AutoRegisterActionServlet.process(AutoRegi
sterActionServlet.java:527)
atcom.bea.wlw.netui.pageflow.PageFlowActionServlet.process(PageFlowActi
onServlet.java:152)
atorg.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
atweblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:971)
atweblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:402)
atweblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
atweblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
va:27)
atcom.bea.p13n.servlets.PortalServletFilter.doFilter(PortalServletFilte
r.java:313)
atweblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
va:27)
atweblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispat
cherImpl.java:305)
atcom.bea.wlw.netui.pageflow.PageFlowRequestProcessor.superForward(Page
FlowRequestProcessor.java:1304)
atcom.bea.wlw.netui.pageflow.PageFlowRequestProcessor$DefaultHttpRedire
ctor.forward(PageFlowRequestProcessor.java:1320)
atcom.bea.wlw.netui.pageflow.PageFlowRequestProcessor.doForward(PageFlo
wRequestProcessor.java:1200)
atcom.bea.wlw.netui.pageflow.PageFlowRequestProcessor.process(PageFlowR
equestProcessor.java:638)
atcom.bea.wlw.netui.pageflow.AutoRegisterActionServlet.process(AutoRegi
sterActionServlet.java:527)
atcom.bea.wlw.netui.pageflow.PageFlowActionServlet.process(PageFlowActi
onServlet.java:152)
atorg.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
atweblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:971)
atweblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:402)
atweblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
atweblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
va:27)
atcom.bea.p13n.servlets.PortalServletFilter.doFilter(PortalServletFilte
r.java:313)
atweblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
va:27)
atweblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:6356)
atweblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:317)
atweblogic.security.service.SecurityManager.runAs(SecurityManager.java:
118)
atweblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:3635)
atweblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2585)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
>
Also, there is no luck with displaying text content from a file, usingprintDoc
tag. Can some one point me to right resource.

Similar Messages

  • My iphone 4s suddenly displays images from Yahoo, Google, and Flickr at low resolution. The camera on my phone works fine, but any web related photo content is now pixelated and low res, what's the deal?

    My iphone 4s suddenly displays images from Yahoo, Google, and Flickr at a low resolution. I have IOS 7.0.4. My phone camera works fine, but any web based photo content from Safari, Yahoo images, Google images, and Flickr all come in pixelated and low res. What's the deal?

    It happened to me but later I figured out that cellular signal was not that great and so the Internet was very slow. It took me about 2 minutes to get the full resolution picuture on either of the app you've described. Try to get faster internet either by wifi or good signal and then check.

  • Error while getting  image from database in SUP using ios?

    Hi All,
      Im developing native iOS application using sup 2.1.3 . Im getting error While retrieving  image from SUP database. Here i'm trying to get image from database and show in imageView.can any one help me how to fix this issue?
    In database image datatype is  'LONG Binary' .
    My table Schema:
    CREATE TABLE dba.ImagesTable (
    RowID INT NOT NULL,
    ImageName VARCHAR(20) NOT NULL,
    PhotoData LONG BINARY NOT NULL,
    IN SYSTEM
    ALTER TABLE dba.ImagesTable
      ADD CONSTRAINT ASA137 PRIMARY KEY CLUSTERED (RowID)
    ALTER TABLE dba.ImagesTable
      ADD CONSTRAINT ASA138 UNIQUE NONCLUSTERED (RowID)
    in Xcode:
                [SUP107SUP107DB synchronize];
                SUP107ImagesTable *imgTable =[[SUP107ImagesTable alloc]init];
                SUP107ImagesTableList *list =[SUP107ImagesTable findAll];
                SUP107ImagesTable * oneRecord =[list objectAtIndex:0];
                NSLog(@"rowId:%d---imageName:%@---photoData:%@---photoLenght:%d",oneRecord.rowID,oneRecord.imageName,oneRecord.photoData,oneRecord.photoDataLength);
                NSData *tempData =[[NSData alloc]init];
                SUPBigBinary *responseBinaryData = (SUPBigBinary *)oneRecord.photoData.value;
                @try {
                    [responseBinaryData openForWrite:[oneRecord.photoData length]];
                    [responseBinaryData write:tempData];
                @catch (NSException *exception) {
                    NSLog(@"exception: %@",[exception description]);
                UIImageView *imgView =[[UIImageView alloc] initWithFrame:CGRectMake(50,50,100,100)];
                [self.window addSubview:imgView];
                UIImage * tempImage =[UIImage imageWithData:tempData];
                imgView.image = tempImage;
                [responseBinaryData close];
    Error Log:
    2014-04-02 18:42:15.150 SUP102[2873:70b] rowId:1---imageName:Apple---photoData:SUPBigBinary: column=c pending=1 allow_pending_state=1 table=sup107_1_0_imagestable mbo=0x0 key=(null) ---photoLenght:90656
    Printing description of responseBinaryData:
    <OS_dispatch_data: data[0xc891b40] = { leaf, size = 90656, buf = 0x1213a000 }>
    2014-04-02 18:42:33.304 SUP102[2873:70b] -[OS_dispatch_data openForWrite:]: unrecognized selector sent to instance 0xc891b40
    2014-04-02 18:42:33.305 SUP102[2873:70b] exception: -[OS_dispatch_data openForWrite:]: unrecognized selector sent to instance 0xc891b40
    2014-04-02 18:42:33.305 SUP102[2873:70b] -[OS_dispatch_data close]: unrecognized selector sent to instance 0xc891b40
    2014-04-02 18:42:33.306 SUP102[2873:70b] [ERROR] [AppDelegate.m:497] NSInvalidArgumentException: -[OS_dispatch_data close]: unrecognized selector sent to instance 0xc891b40

    This thread talks about uploading image to SAP from a IOS device,Sending Image to SAP via iOS Native app (SUP 2.1.3)
    Midhun VP

  • 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 image stored @ content managemenbt

    Hi,
    this is regarding to displaying image stored @ content management, using <html:img> tag in .jsp
    under a node i am uploading two images. (node having two upload options)
    in .jsp i am using <html:img> tag to display the images.
    i tried to display both the images. But the first image what i upload is not showing. what i upload second is displaying.
    pls let me know how to resolve this.
    Thanks.

    You need to access binary property values separately from the node. In 9.2 the API is accessed via INodeManager.getStream(). Alternatively you can take advantage of the tags we have for this as well. Take a look here on edocs:
    http://e-docs.bea.com/wlp/docs92/cm/developCM.html
    -Ryan

  • 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

  • Display image from table!

    Hi,
    I have in my aplication a table user, where we can save is image:
    t_user{id_user, name , adress..., foto(blob),foto_size(number),foto_name,foto_mime_type};
    An user can upload his imageand save it in his table!
    I wanted to display his image, but i onle found infomation how to show images saved in htmldb_application_files:
    how to display image from tables?
    Thank's in advance

    Look at the sample application. It shows you how to do this

  • Display images from a SQL database

    I want to display images from a SQL database. The images are in a table under a specific column and are stored as a link to the image. How would I display the images from the column in LabVIEW?
    I'm using LabVIEW 2013 version 13 and SQL Server 2012
    Paul Power
    I have not lost my mind, it's backed up on a disk somewhere

    Hi PauldePaor,
    I hope you are well.
    Once you have pulled the data from the database into LabVIEW in a string form (or path), you can simply use the Read BMP File (Or jpg, png depending on the file type) VI.
    More information can be found here:
    http://digital.ni.com/public.nsf/allkb/02971A30F5D8FC6986256A0A004F11A0
    Kind Regards,
    Aidan H
    Applications Engineer
    National Instruments UK & Ireland

  • My RGB colors are turning to cmyk while bringing image from illustrator or photoshop. Why?  Removing the image from that page bright RGB colors are back.. hmm

    My RGB colors are turning to cmyk while bringing image from illustrator or photoshop. Why? 
    Removing the image from that page bright RGB colors are back.. hmm

    Edit > Transparency Blend Space > Document RGB

  • How to display image from wamp if the data type i use is blob?

    please help me with the problem of displaying image from wamp if data type is blob. Thanks

    Don't store the images in the database. Store the image file names in the database and put the images in a folder.

  • Displaying images from url's (9i)

    Is it possible to some how display images retrieved from a url within an image item? I know its possible to display images from within the database and from a file but these images are stored on another server and all i have is a web address, can it be done? Also is it possible to dislpay a series of images that are retrieved in this way in a report?
    Any help is much appreciated.

    Hi,
    this would require a Java Bean to be written. Its not natively possible in Forms
    Frank

  • 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();
    %>

  • Displaying image from database

    Hello. I have this problem if anyone can help. I have an image inserted into a MySQL database. But when I try to display it using JSP I get a screen full of funny characters and do not display. The code I use is below.
    String sql2 = "Select image1 from images";
    ResultSet rs2 = stmt.executeQuery(sql2);
    if(rs2.next())
    InputStream in = rs2.getBinaryStream("image1");
    response.setContentType("image/jpg");
    ServletOutputStream sout = response.getOutputStream();
    int c;
    while((c = in.read()) != -1)
    sout.write(c);
    in.close();
    sout.close();
    I tried using the code below, but that don't work either.
    %>
    <tr>
    <td><img src="<%= rs2.getString("image2") %>"></td>
    </tr>
    <%
    What am I doing wrong here? Is it better to grab the image straight out of a directory? If so, how? The image would be on the Tomcat4 server in the root directory.

    When a html page is downloaded to the client, each image, css include, *.js include etc.. are fetch one at a time. So you would want to write a servlet that is mapped to something like /database/image/name.jpg and this servlet would be responible for pulling the image from the database, setting the proper MIME type and writing it to the client.
    In your case, you are writing the image content to the client within the jsp page. This explains the char's you see within the page.
    Things you should do:
    Create custom servlet which will pull the images from the database.
    map the servlet to what ever patteren you like. (web.xml file you would edit)
    Set the mime type and write the image.
    I hope this is of help.

  • Display Images from Database

    Hi all,
    I require to display images stored in database along with textual description of it on a JSP.
    The image file should not be stored intermediately on file system (i.e w/o using img HTML tag)
    It is a typical shopping cart appln. where images are fetched from database and the associated description is displayed along side.
    Please note that it is the case of Mixed content types(text and binary data).
    Thanks and Regards

    Like "Breakfast" said, you can do this with a servlet that retrieves your images from a database....
    if you create a servlet to do this, you would have a generic servlet which retrieves a picture from a database based upon a key which could be a picture name or number.
    Lets say the file is out there in the database as a BLOB or Binary Image... you could have this kind of code in the doPost(HttpRequest req, HttpResponse res) or doService(HttpRequest req, HttpResponse res) method.
    The table holding the image has at least two columns one called IMAGE which holds the binary image and the other called FILENAME. If the connection to the DB is already open, you do something like this.
    String fileToGet = (String)req.getParameter("FILENAME");
    rs = conn.createStatement().executeQuery("select from IMAGE_TABLE where FILENAME='" + fileToGet + "'");
    if(rs.next())
    InputStream in = rs.getBinaryStream("IMAGE");
    res.setContentType("image/jpg"); // or whatever type of file it is.
    ServletOutputStream sout = res.getOutputStream();
    int c;
    while((c = in.read()) != -1)
    sout.write(c);
    in.close();
    sout.close();
    This should write your image to the response output of the servlet.
    Now, where you want your image, you put.
    <img src="/servlet/ImageServlet?FILENAME="thefileIwant">
    This should do what you want... Use your favorite pipe copy method to get the input stream to the output stream. If you are worried about overhead and scaling like "breakfast" said (it CAN be a problem in high access sites), then you can add an image caching scheme and get really complex.... But this is a rough idea on what to do.
    Hope this helps.
    Stephen McConnell

  • How to display images from BLOB column via APEX 4.0

    Hello,
    I did the following in order to display images of two Oracle records on the APEX page. I am using APEX Version : 4.0.1.00.03 , Oracle DB Version : 10.2.0.4.0.
    1. Created An oracle table TEST_FORM
    with 3 columns
    ( ID number, MIME_TYPE varchar2(255) , Image BLOB )
    2. Inserted two records
    10001, image/gif, ( actual image1)
    10002, image/gif, ( actual image2)
    3. created an Oracle procedure
    CREATE OR REPLACE PROCEDURE show_my_form ( p_image_id IN test_form.id%type) AS
    l_mime test_form.mime_type%type;
    l_length NUMBER;
    l_file_name VARCHAR2 (2000);
    lob_loc test_form.IMAGE%type;
    BEGIN
    SELECT mime_type, IMAGE
    , DBMS_LOB.getlength (IMAGE)
    INTO l_mime, lob_loc, l_length
    FROM test_form
    WHERE id = p_image_id;
    owa_util.mime_header(l_mime, false);
    htp.p ('Content-length: ' || l_length);
    owa_util.http_header_close;
    wpg_docload.download_file (lob_loc);
    END show_my_form ;
    4. In Apex 4.0
    step1. Created an interactive report on a new APEX page
    step2. Specified the following in the Region Source
    select id, mime_type, '<img src="#OWNER#.show_my_form ?p_image_id=#ID#" />' photo
    from TEST_FORM
    The column result shows as <img src="CCS.show_my_form?p_image_id=#ID#" />
    I am unable to display the column image as a link to a proper image photo.
    Could you please advise me if I missed anything ?
    Thanks a lot.
    Regards
    Susanna
    Edited by: user10318332 on 13/12/2010 15:51
    Edited by: user10318332 on 13/12/2010 20:10

    Maybe the space you have before the ? is causing issues. there shouldn't be any space.
    Your procedure looks to be much the same of one that I have.
    Have you granted execute on your procedure?
    Also, what version DB are you running? This could be another issue: http://daust.blogspot.com/2006/04/xe-calling-stored-procedures.html
    But anyway, you don't need to create your own procedure these days. You could do the following:
    in your query, have a column: dbms_lob.getlength(blob) photo ; save, then in column attributes for that column, apply a format mask. There is usually a link below the text box for the format mask - BLOB Download Format Mask, which will help you build the format mask. But it is documented here: http://download.oracle.com/docs/cd/E17556_01/doc/user.40/e15517/advnc.htm#BCGGJHEF
    Ta,
    Trent

Maybe you are looking for

  • HP Photosmart 2570 series fax (via HP Scan Pro) gone

    With the latest Tiger update (Mac OS X 10.4.11 (8S165)) I now do not have the scanning function of my HP Photosmart 2575 alive. I have HP Scan Pro.app version 6.1.4 (13.5.05). The printer is serial number MY62E120B904DY. If I try to start HP Scan Pro

  • Skipping to a specific place in a recursive function

    I wrote a recursive function that recurses Adding times, then calls go (). The entire function will call go () billions of times. When I call this function, I want to only run go () 5,000,000 times. It should run the first 5,000,000 go's if the Part

  • TS4006 my iphone 4s isnt picked up by my macbook pro or itunes... help!

    i have tried multiple computers, different USB cords, reinstalling itunes after removing folders I cant back it up cause it wont register that iv connected anything to the computer... however it still charges when connected Its currently at 100%... b

  • Lost apps with new update

    I updated to IOS 7 and it went well....With the exception my entire second page of apps didn't show up.  It says they are on my phone and I can "open" them but I can't find the app short cut.  I am unable to delete and then re install.  Any ideas? Th

  • Number assignment for vendor account group

    Hi all, I would like to assign no range for my newly created vendor account group in xkn1 But how to create it with reference to my acocunt group....kindly explain in detail tks kali