Displaying Image from byte[ ]
I am using Webservice for data control and ADF UI (Jdev 11.1.1.3)
I need to display image on jsff using the byte[] I receive from web service which fetches data from BLOB column in DB. Is there any way apart from ImageServlet because I am not allowed to access DB.
Thanks in advance. Amit
ImageServlet doesn't mean that you need to access data from DB. af:image needs a source, so ImageServlet acts as source for this, the implementation of data retrieval can be modified as per your use case.
Similar Messages
-
Hello Everybody,
I need to display an image given in a byte array, how can I show this image in a JFrame?
1. I tryied saving the image in a .jpg file,
File file1 = new File("Path to my destination image");2. then I use a FileOutputStream to save the image in the path:
FileOutputStream fos1 = new FileOutputStream(docu);
fos1.write(ImageInbyteArray);
fos1.close();3. Once I have the image in a file I'm trying to load it using a JButton, but the JButton doesn't display the image. I think that for some unknown (at least for me ;-) reason the file isn't still available to be used in the ImageIcon, this is my code:
imgIconDocu = new ImageIcon("Path to my destination image");
jBtnDocu = new JButton(imgIconDocu);What's wrong here?
Thanks a lotDoes the byte array contain a JPEG image? Where did
you get the contents of the byte array?yes the array contains the JPEG image, I have a database in PostgreSQL, and the images are stored in blob in the database. I have to call a service in the server and in return it gives me the 3 images as byte arrays, that's the reason I only have the byte arrays. so I tryed saving the images as jpeg files in my hard disk to show them, but it appears that they are not available to show them in Swing after saving them. I can only show the images if I close my application and start it again :-(
I tryed flushing and closing the FileOutputStream after the writting process (fos.write(bytearrayImage);
fos.flush();
fos.close();)
Y also tryed:
fos.write(bytearrayImage);
fos.close();
fos.flush();But it doesn't work either :-(
What do you recommend me?.
Thanks a lot,
Johnny G L -
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.
ImtiazHello,
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 -
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.
-
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 advanceLook at the sample application. It shows you how to do this
-
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:
luddite1812I 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 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 somewhereHi 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 -
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 -
Displaying image from Webserver on to a Swing application
Hi guys,
We're developing an application that is typically swing <-> servlet <-> database.We want to retrieve an image present on the server system through a servlet( which actually gets the path of the image stored in the database and returns that image file on the HDD of server system as a byte[ ]).
My problem is im reading the image from the byte[ ] on the swing client and creating a new .gif file on the client system but couldnt create its dimensions.hence not able to display it on my app.Plz help.Thx for ur consideration.
my code looks as -
//this is Swing client
try
String query="select imgpath from emp_img where eid=1";
URL u=new URL("http://127.0.0.1:8080/servlets-examples/servlet/ImgServ?query="+URLEncoder.encode (query));
URLConnection uc=u.openConnection();
ObjectInputStream ois=new ObjectInputStream(uc.getInputStream());
byte b[]=(byte[])ois.readObject();
System.out.println("b size= "+b.length);
FileOutputStream fos=new FileOutputStream("emp.gif");
fos.write(b);
Graphics g=EmpImg.getGraphics(); //EmpImg is JButton
EmpImg.setIcon(new ImageIcon("emp.gif","pic"));
EmpImg.updateUI();
catch()......
bye
neilHi guys,
We're developing an application that is typically
swing <-> servlet <-> database.We want to retrieve an
image present on the server system through a servlet(
which actually gets the path of the image stored in
the database and returns that image file on the HDD of
server system as a byte[ ]).
My problem is im reading the image from the byte[ ] on
the swing client and creating a new .gif file on the
client system but couldnt create its dimensions.hence
not able to display it on my app.Plz help.Thx for ur
consideration.
my code looks as -
//this is Swing client
try
String query="select imgpath from emp_img where
eid=1";
URL u=new
URL("http://127.0.0.1:8080/servlets-examples/servlet/Im
Serv?query="+URLEncoder.encode (query));
URLConnection uc=u.openConnection();
ObjectInputStream ois=new
ObjectInputStream(uc.getInputStream());
byte b[]=(byte[])ois.readObject();
System.out.println("b size= "+b.length);
FileOutputStream fos=new FileOutputStream("emp.gif");
fos.write(b);
Graphics g=EmpImg.getGraphics(); //EmpImg is JButton
EmpImg.setIcon(new ImageIcon("emp.gif","pic"));
EmpImg.updateUI();
catch()......
bye
neilAre sure that you've closed fos?
fos.close();Probably file is incomplete?
Paul -
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
SajidI 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();
%> -
Hi Experts,
I want to display images of the respective employees from the R3 system. How can i do it? In what format the image will be sent from R3?
Thanks & Regards,
Mugundhan.AHi,
1. Create an attribute 'BinImg' of type 'binary' in context. Save binary stream returned from BAPI in this attribute.
2. Create another attribute 'MyImage' of type String.
3. Go to view layout. Create an UI element image. Map its source property to MyImage attribute.
4. Once you have saved binary stream from BAPI, use following code to display image:
byte b[]=wdContext.currentContextElement().getBinImg();
IWDResource res=WDResourceFactory.createCachedResource(b,"R3Image",WDWebResourceType.JPG_IMAGE);
String imgStr= res.getUrl(WDFileDownloadBehaviour.OPEN_INPLACE.ordinal());
wdContext.currentContextElement().setMyImage(imgStr);
Regards,
Deepti -
Displaying image from binary file
I am converting a image file(jpg) into a binary file and sending it. In the receiving side i got back the binary file and want to display the image in the applet or store the image in a file. while trying to do this i am not able to read the image from the buffer. Below here i have given my code.
File f= new File("image.jpg");
FileInputStream fis = new FileInputStream(f);
byte [] buffer = new byte[(int)f.length()];
fis.read(buffer,0,buffer.length);
fis.close();
File f1 = new File("input.txt");
int length = buffer.length;
PrintWriter pw;
pw = new PrintWriter(new BufferedWriter(new FileWriter(f1)));
for(int i=0;i<length;i++)
pw.println(Integer.toBinaryString(buffer));
pw.flush();
pw.close();
converting back to image i get error
File f1 = new File("inp.txt");
FileInputStream fis = new FileInputStream(f1);
buffer = new byte[(int)f1.length()];
fis.read(buffer,0,buffer.length);
Toolkit tk = Toolkit.getDefaultToolkit();
img = tk.createImage(buffer);
Reply me as early as possible.thanks.You have two glaring problems here.
Firstly, you are writing via writers, which are intended for text and are probably corrupting your data. You want to be using a FileOutputStream.
Secondly, when reading in you are not checking the number of bytes read and may well not be fully populating your array. You want to change your reading code to something like this,
buffer = new byte[(int)f1.length()];
int read = 0;
while (f1.available() > 0)
read += fis.read(buffer, read, buffer.length - read);
} -
Displaying image from binary code
I am converting a image file(jpg) into a binary file and sending it. In the receiving side i get the binary file and want to display the image in the applet or store the image in a file. while trying to do this i am not able to read the image from the buffer. Below here i have given my code.
File f= new File("image.jpg");
FileInputStream fis = new FileInputStream(f);
byte [] buffer = new byte[(int)f.length()];
fis.read(buffer,0,buffer.length);
fis.close();
File f1 = new File("input.txt");
int length = buffer.length;
PrintWriter pw;
pw = new PrintWriter(new BufferedWriter(new FileWriter(f1)));
for(int i=0;i<length;i++)
pw.println(Integer.toBinaryString(buffer));
pw.flush();
pw.close();
converting back to image i get error
File f1 = new File("inp.txt");
FileInputStream fis = new FileInputStream(f1);
buffer = new byte[(int)f1.length()];
fis.read(buffer,0,buffer.length);
Toolkit tk = Toolkit.getDefaultToolkit();
img = tk.createImage(buffer);
Reply me as early as possible.thanks.You have two glaring problems here.
Firstly, you are writing via writers, which are intended for text and are probably corrupting your data. You want to be using a FileOutputStream.
Secondly, when reading in you are not checking the number of bytes read and may well not be fully populating your array. You want to change your reading code to something like this,
buffer = new byte[(int)f1.length()];
int read = 0;
while (f1.available() > 0)
read += fis.read(buffer, read, buffer.length - read);
} -
Displaying image from database in report
I need to include a picture (company logo) in numerous reports. This logo will be stored in an MS SQL Image field in a table (this bit I have already sorted out).
What I'm wondering is, what is the best way to retrieve this image from the database? Do I just include it in the view the report runs off? I'm hesitant to do this, as the view may return back hundreds of records, which means (I think) it will be sending the image along with it hundreds in time.
In short:
1) What is the best way to pass an image to a report.
2) If I include the Image field in a view which returns back hundreds of line, will the image be returned also hundreds of time, causing network congestion/performance issues?
3) If so (2), is there a way of sending the image only once, no matter how many rows are in the returned view?
Thanks.Hi Shanon,
We can display the image by making it a local copy on your machine.
If it is possible to get the image saved on local copy.
If we place the image in detail section then it would return one record.
As the image is from Database, so it would hit the database very time when you refresh the report and place it in Report Header or report fotter.
So, place your logo as an OLE object in report and would reduce processing time.
Regards,
Naveen.
Maybe you are looking for
-
Ever since installing Mountain LIon my caps lock no longer works. Any ideas?
ever since downloading Moutain Lion my cap lock no longer works, Any ideas?
-
Urgent :- Issue with deploying application in Oracle Application server
Hello All, Hope all of you are doing good ! I am facing an issue relating to deploying applications using the Enterprise manager. When i deploy the war file using Deploy WAR file option in the OEM, i get the following error - Failed to deploy web app
-
Import error: An error occurred whilst running the import.
--------------------------- Import error An error occurred whilst running the import. The import log file will now be opened. Exception details: Microsoft.SharePoint.SPException: The file WO_11_12_A_109/STAGE 1ST has been modified by (unknown) on 2
-
Where are Develop Default Settings stored for LR 5 in Win 8.1
I want to use my Default Settings on another computer, so I need to find them and then copy them to the correct folder in the second computer. Second question. If I also happen to apply a Preset during Import that has some of the same Develops as my
-
Download Bash script running from Task-bar folder
Hi, Not sure why but when Im trying to open my Downloads file from the task bar its openning up on my desktop as "Downloads-Bash script! how do i stop this please. Its the same if I open from Finder. Thank you all in anticipation of a resolve.