Display gif files using servletoutputstream (again)
Hello,
I'm trying to display several gifs files in a html file. I extract all the files from an oracle database. I'm trying to use a servletoutputstream, but it does not difference between text and image.
Process:
1. Select html file from database
2. Go through each line of html file to find the links to gif files
- if gif :
3. Ask for the gif file detected and select from database
4. use servletoutputstream to display the file
- end of if
-else
5. display the line of text.
Is it possible to use a servletoutputstream to display several gifs and text content?
Is there one other solution to do it correctly?
Thanks in advance,
Angela.
The code I use is:
private void retrieveFile()
FileWriter fwHtml=null;
oracle.sql.BLOB blob=null;
InputStream in=null;
ServletOutputStream out=null;
ResultSet rsGif=null;
try
//Extract html file from the database
String query="SELECT * FROM DBFiles WHERE FILENAME='"+file+"'";
PreparedStatement ps = connection.prepareStatement (query);
ResultSet rs=ps.executeQuery();
rs.next();
String fileName=rs.getString("FILENAME");
if (fileName.indexOf("html")!=-1)
InputStream fis=rs.getAsciiStream(5);
//I read each line to know where the html file calls the links to the gif files
BufferedReader reader= new BufferedReader(new InputStreamReader(fis));
String line;
String mimeType="";
try{
while ((line=reader.readLine()) !=null)
if((line.indexOf("img src="))!=-1)
int imgIndex=line.indexOf("img src=");
int altIndex=line.indexOf(" alt=");
//I obtain the name of the gif file that I obtain from the database
String gifFile=line.substring(imgIndex+9,altIndex-1);
query="SELECT * FROM DBFiles WHERE FILENAME='"+gifFile+"'";
ps.clearParameters();
ps = connection.prepareStatement (query);
rsGif=ps.executeQuery();
rsGif.next();
blob=((OracleResultSet)rsGif).getBLOB("GIF");
String gifName=rsGif.getString("FILENAME");
mimeType = context.getMimeType(gifName);
response.setContentType(mimeType);
out = response.getOutputStream();
in=blob.getBinaryStream();
int bufferSize=blob.getBufferSize();
byte[] buffer = new byte[bufferSize];
int bytesRead=0;
int intBuffer=in.read(buffer);
while ((bytesRead=intBuffer)!= -1)
out.write(buffer,0,bytesRead);
in.close;
else
byte[] bString =line.getBytes();
mimeType = context.getMimeType(fileName);
response.setContentType(mimeType);
out.write(bString,0,line.length());
catch (IOException ioe) {
System.out.println("Unable to open Image file "); ioe.printStackTrace();
finally {
if (out != null) {
out.flush();
out.close();
ps.clearParameters();
connection.commit();
rsGif.close();
rs.close();
ps.close();
catch (SQLException sqle)
sqle.printStackTrace();
catch (Exception e)
e.printStackTrace();
Let's put it this way, since I don't have the patience to look at your code. HTML cannot have images embedded in it, it can only have links to images. So you could have a servlet that sends an image, but only a single image and nothing else. I see you have code to set the MIME type of the image, so I don't have to tell you about that.
Similar Messages
-
Show several gifs files using servletOutputstream
Hello,
I'm trying to display several gifs files in a html file. I extract all the files from an oracle database. I'm trying to use a servletoutputstream, but it does not difference between text and image.
Process:
1. Select html file from database
2. Go through each line of html file to find the links to gif files
- if gif :
3. Ask for the gif file detected and select from database
4. use servletoutputstream to display the file
- end of if
-else
5. display the line of text.
Is it possible to use a servletoutputstream to display several gifs and text content?
Is there one other solution to do it correctly?
Thanks in advance,
Angela.
The code I use is:
private void retrieveFile()
FileWriter fwHtml=null;
oracle.sql.BLOB blob=null;
InputStream in=null;
ServletOutputStream out=null;
ResultSet rsGif=null;
try
//Extract html file from the database
String query="SELECT * FROM DBFiles WHERE FILENAME='"+file+"'";
PreparedStatement ps = connection.prepareStatement (query);
ResultSet rs=ps.executeQuery();
rs.next();
String fileName=rs.getString("FILENAME");
if (fileName.indexOf("html")!=-1)
InputStream fis=rs.getAsciiStream(5);
//I read each line to know where the html file calls the links to the gif files
BufferedReader reader= new BufferedReader(new InputStreamReader(fis));
String line;
String mimeType="";
try{
while ((line=reader.readLine()) !=null)
if((line.indexOf("img src="))!=-1)
int imgIndex=line.indexOf("img src=");
int altIndex=line.indexOf(" alt=");
//I obtain the name of the gif file that I obtain from the database
String gifFile=line.substring(imgIndex+9,altIndex-1);
query="SELECT * FROM DBFiles WHERE FILENAME='"+gifFile+"'";
ps.clearParameters();
ps = connection.prepareStatement (query);
rsGif=ps.executeQuery();
rsGif.next();
blob=((OracleResultSet)rsGif).getBLOB("GIF");
String gifName=rsGif.getString("FILENAME");
mimeType = context.getMimeType(gifName);
response.setContentType(mimeType);
out = response.getOutputStream();
in=blob.getBinaryStream();
int bufferSize=blob.getBufferSize();
byte[] buffer = new byte[bufferSize];
int bytesRead=0;
int intBuffer=in.read(buffer);
while ((bytesRead=intBuffer)!= -1)
out.write(buffer,0,bytesRead);
in.close;
else
byte[] bString =line.getBytes();
mimeType = context.getMimeType(fileName);
response.setContentType(mimeType);
out.write(bString,0,line.length());
catch (IOException ioe) {
System.out.println("Unable to open Image file "); ioe.printStackTrace();
finally {
if (out != null) {
out.flush();
out.close();
ps.clearParameters();
connection.commit();
rsGif.close();
rs.close();
ps.close();
catch (SQLException sqle)
sqle.printStackTrace();
catch (Exception e)
e.printStackTrace();I may be wrong, but I don't think HTML supports inlining image data for a page. I think you need to let the client process the HTML and make requests to your servlet for specific images; it is at this point they should be read from the database and returned to the client.
So I'll change your algorithm to
1. Select html from the database
2. Return it to the client
3. Client makes request for an image (<img src="servlet?image=name">) maybe
4. Servlet reads image from the db
5. Servlet set appropriate header information (image/gif etc)
6. Servlet outputs image data. -
Why java only can display GIF file not jpeg and BMP ??
Did anyone know why java only can display GIF file not in jpeg and BMP ?? This is because the quality of GIS is not as good as Jpeg and BMP
any code to load the display process ??
thx guys !!!you can do jpegs but im not sure about bmps.
The only thing ive noticed is that java cant support transparent jpegs, only transparent gifs
Jim -
How to edit existing gif file using photoshop (CS2)
Hello Forum,
I have some gif images that I have used for creating tabs on a
web page. I downloaded these images from somewhere, and did not create them
myself. I would like to change the color of these gif files.
They are a nice image, with a gradient applied at the top, and I have a left side gif for the tab as well as an "over" image set for the tab(s) as well.
I use the images in a css file to display the tabs on a web page.
The gradient is across the top of the tab, which is a lighter color, almost going to white, and the rest of the tab is a light blue, with left and right top a slight rounded corner. I would like to preserve the gradient appearance, but change the light blue theme to an almost black (#333333) color.
How can I do this in photoshop?
Thanks,
eholz1Hi All
I would like to create an action in CS2 to resize an image to e.g 600 x ? pixels and then save for web at max 149kb .
Any clues? I've tried a few different files of different file sizes?(possible cause here) and always end up with different results when using my actions or the image processor.
Is this at all possibleto accomplish in a single step?
Let me elaborate more. On a particular forum where post we are limited to 600 x? pixels and file size no greater than 150 kb. When creating this action in CS2 with different file sizes one lands up with files ranging from 70kb (not as good for viewing) to 149kb(perfect size)or 357kb?(way too big). I'd like to have as close to <150kb for ALL files in the "action"
Is this possible without getting into scripting?
Thanks
Don -
How do I display .gif files in Mail?
This has bugged me for a long time. When I get an email that has web graphics in it (usually .gif files) I can't see it in Mail at all. I just get a red box. I am using Mac OS 10.2.8.
Hi Canterbury
Welcome to Discussions
In Mail 1.3 Preferences, click the viewing tab and check the box that says Display images in HTML messages.
I don't know if you can do the same in Mail 1.0 for Jaguar, but have look.
good luck
regards roam -
How to display HTML files using ABAP Webdynpro?
Hi,
I have a html index file and a bunch of other files accessed by the index file in a specific directory on the SAP server. I'd like to display the index file via ABAP webdynpro and allow the users to click on what they need to see. How can I achieve this using utilizing the ABAP webdynpro technology ?
Thanks!Hi Thomas,
Thanks for taking the time to answer my question.
I have the main html file and all other files needed by the main file in one directory on the application layer of SAP. I'd like to provide the user with a link, by clicking on which they should be able to get to the main html file using the browser. This is just a standalone application.
I can try the approach using BSPs, however, I'm new to that area. Could you point me in the right direction to get started? -
Display pdf file using webdynpro abap
Hi Friends,
My requirement is to display pdf file in the second page with the input text entered in the fisrt page when clicked on action
button( in the first page) using webdynpro abap.
Can anybody explain the step by step procedure as I am new to this area.
Thanks in advance.
Reagrds,
NagarajuHi,
Check this.,
Creating a PDF file in webdynpro abap.
Web Dynpro ABAP display pdf
hope this helps u.,
Thanks & Regards
Kiran -
I am wondering if there is any way by which we can request for a web resource from portal to portlet provider.
Currently if in order to display image I need to make direct request to portlet provider rather than routing the request through portal. As a result of this there is no session affiliation.
My web resource can also be .jsp or .html file
Any suggestions are welcome.Hi Hernando,
It seems I haven't put my question correctly, probably following might help me explain you what I require:
Portlets are added to portal page. Portlet content is served by portlet provider. So when you are viewing a portal page containing portlets in reality portal requests the portlet data from portlet-provider. So the actual request flow is: Request for a portal page, portal analyzes portlets on the page, and then request the portlet provider for the content associated with portlet. In the exact reversal process data flow is: portlet-provider generates the content which is passed to portal & then portal forwards it to end user.
Now want something similar to happen with images (.gif files). But the problem is I am failing to create a link for this resource. I want the request for image to flow through portal very much the same way as its doing for the content. In other words I want to create a link which would inform portal to request for the resource to portlet provider. In this scenario portlet provider would pass the image to portal which would be forwarded to end user. Currently to get the images I am making direct request to portlet provider there by bypassing the request to flow through portal, which I do not want. Above all this resource can be anything a css file or a image or a .js file.
So can you suggest me how to achieve it? -
How to display mutilpe files using JFile choose
please hepl me regarding how to select and display the mutilpe files using JFile chooser
i m sorry if i have done any mistakes.i am new to
this forum i just wanted to tell my problem and wish
that it could ne solved...Tell it only once. Posting multiple times don't get more attention. -
Issues in displaying .gif files.
hi all,
We hav enabled SSL in our application and its working fine with a trail certificate from verisign, but in each page we are getting a message box saying tht "This page contains secure ad non-secure items and like to proceed".
i believe tht this is becoz of .gif files present in the application. how to solve this issue??
thank youHi Mohan,
# Answer given in the following link
http://www.apluskb.com/scripts/When_accessing_my_site_securely_answer1132.html
When accessing my site securely (using https), it indicates that the page contains secure and non secure items. Why is this happening?
The page you are trying to access refers to some links which are not secure. This is most likely caused by some image tags like this:
IMG src="http://somedomain.com/images/image.jpg"
You have to either replace "http" with "https" or try to use just relative links in your html (which is better) as:
IMG src="images/image.jpg"
Found related information in the following links:
# Warning: "This page contains both secure and nonsecure items"
http://www.alternatiff.com/faq.html#securenonsecure
# User Experience changes
http://blogs.msdn.com/ie/archive/2005/10/22/483795.aspx
Hope it helps.
Regards,
Sindhiya V. -
How to receive a gif file using a custom ABAP FM
Hi Experts,
Here is my requirement.
I have to provide an interface which should receive a GIF file.
I have created a FM but what data type should I define in the import parameter or the table parameter to receive the GIF file (which has been converted to binary format by the other application).
Thanks in advance.Hi,
Do not type it to any associated type.
Create a tables parameter with some name.
Actually the FM GUI_UPLOAD does the same thing(Just that it is not RFC enabled).
YOu can check its code.
Regards,
Ravi -
Display Excel File using OfficeControl
Hi,
My requirement is to display and Excel file for approval purpose which is generated by custom ABAP application. After each approval I need to again generate the Excel file with the approval name added and send for next approval.
Is it possible to download the Excel File to application server and display it on webdynpro screen.
Please let me know if they are other methods to achieve the same.
Thank you,
Ramu N.Hi Ramu,
Yes you can do this by using File upload and download methods. using this you can upload and download excel files.
Check this wiki..
http://wiki.sdn.sap.com/wiki/display/WDABAP/UploadandDownloadfilesinWebdynproABAP
http://wiki.sdn.sap.com/wiki/display/WDABAP/ExcelFileUploadAndDisplayDataUsingWebDynPro+ABAP
using office control...Check this...
How to use element FILE_UPLOAD with element OFFICE_CONTROL
http://help.sap.com/saphelp_nw2004s/helpdata/en/d1/af8841349e1909e10000000a155106/frameset.htm
Cheers,
Kris.
Edited by: kissnas on May 19, 2011 6:36 AM -
Problem displaying tiff files using ADF
Hi,
I have some TIFF files in a table - IMAGE_TABLE
ID NOT NULL NUMBER
DESCRIPTION VARCHAR2(40)
IMAGE ORDSYS.ORDIMAGE
I am unable to display TIFF images in an ADF form. I can use processCopy to convert the TIFF images to jpeg, which them display correctly. All other JPEG or GIF display correctly, it's only the TIFF that don't. I've tried variours tiff files (different sources, converted gif and jpeg to tiff) but none display correctly (i.e. in IE you get the red 'x' - in firefox you get the broken picture symbol or nothing)?
This appears to be an ADF issue as I 'can' dsiplay the TIFF files correctly in IE and firefox using the quicktime plugin but not from an ADF form using JDdevloper? (The code/application is Steve Muench's JSFOrdImageExample - http://otn.oracle.com/products/jdev/tips/muench/jsfordimage/JSFOrdImageExample.zip)
Any ideas or suggestion would be appreciated.
Thanks.
JDeveloper 10.1.3 build 10.1.3.0.4
DB is 10gr2Hi,
yes, I can view tiff's in browsers (IE and firefox) using the quicktime plugin. I've selected quicktime as the player in the af:objectmedia property settings and Autostart = true, but using the ADF form from JDeveloper will not display tiff images (jpg's, giff's etc. are fine) even though the browser will display tiff's on it's own?
Thanks. -
Displaying HTML file using IFrame
Hi All,
I have an HTML file in my par file. It is contained as dist\html\test.html. Now I want to display this inside an IFrame. If I try something like
<iframe id="myIframe" src="html\test.html" width=100% height=100% frameborder="0"></iframe>
it fails to load the HTML file. Please let me know how to display this.
Thanks in advance
ShubhadipHi George,
as per your suggestion I have used
<% String html = componentRequest.getWebResourcePath() + "/html/test.html";%>
<iframe id="myIframe" src=<%=html %> width=100% height=100% frameborder="0"></iframe>
But its not working.. giving the following error:
Portal Runtime Error
An exception occurred while processing a request for :
iView : pcd:com.sap.portal.system/temporaryobjects3/9b20d054b8a1ab8c2cd5d105cde1788c/TestDynPage
Component Name : null
Page could not create the iView.
But if I give some web url like yahoo.com it works fine. How to do it then?
Thanks,
Shubhadip -
Hi all,
how can i display a log file from server using java applet.
rgds
geethaBuild a tail-daemon using netcat or inetd, then have a socket from the applet connect to the service thus created, and display using some simple java.awt.Canvas or some other text-displayer in the awt or swing. Viola. Just means that everyone else can see your logfile as well, so why not just remove that firewall ?
Maybe you are looking for
-
I tried dragging songs onto my iPod but it keeps saying the error message from above. I've looked at other threads and tried what they say but the thing is that I manually sync my iPod, rather than having the settings for iTunes to sync it for me tur
-
Two different X sessions; one on tty7/one on tty8
Is it possible to have user foo have an X session on tty7 and to have user bar have an X session on tty8? One can run gdm or lightdm and then 'switch users' but I'd rather not have a greeter at all and just rely on Clt+Alt+F7 or Clt+Alt+F8. Thanks.
-
Hi Guy's I had seen many posts saying that career in MDM will be booming. But on contractary I had seen jon saying that it is good to have skill and that too with BI ( http://www.jonerp.com/component/option,com_jd-wp/Itemid,20/p,40/ ). After read
-
Assign one Componet to another Componet
Hi we have "payment form" view in sales order item details page. But if we open "Credit Memo" item details page, this "Payment Form" is not available. So our Requirement we need "Payment Form" view in "Credit Memo item Details Page" same like "Sales
-
I have used keychain for years, but I never bothered to learn enough what it can help me with some parts. I am mainly looking into about part line about the "Where:" section for it which I have attached which I have found through google to help my qu