Sending Image to Browser

Hello Guys !
I need to load TIFF Image on Browser. Before this I'm converting to JPEG format whitout saving image on disk, just sending it to browser. This is the point: how can I format image in HTML format ?
response.setContentType("image/jpeg");       
        ServletOutputStream sos = response.getOutputStream();
        RenderedOp src = JAI.create("fileload", "g:\\java\\00000001.TIF");
        ImageEncoder encoder = ImageCodec.createImageEncoder("JPEG",sos,null);       
        encoder.encode(src);Thanks !

OK ! Now I see. But I don't know how to do that.
I created a JSP FILE:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="obj.*"%>
<%
  NewServlet objServlet = new NewServlet(); 
  out.println("<img src=" + ?????????? + "/>"); 
%>
<html>
<head><title>Image View</title></head>
<body>
</body>
</html>And have a code in NewServlet:
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {       
        response.setContentType("image/jpeg");       
        ServletOutputStream sos = response.getOutputStream();
        RenderedOp src = JAI.create("fileload", "g:\\java\\00000001.TIF");
        ImageEncoder encoder = ImageCodec.createImageEncoder("JPEG",sos,null);       
        encoder.encode(src);       
    }HOW CAN I LINK THE NEWSERVLET WITH JSP FILE ???
PS: I HOPE I'M NOT BORING YOU !!!!
THANKS !

Similar Messages

  • Send Image to browser - Firefox issue

    Hi,
    I have implemented the retrieval of an OrdImage from the DB and sending it to a browser using the OrdHttpJspResponseHandler:
    OrdImage media = (OrdImage)result.getCustomDatum(1, OrdImage.getFactory());
    handler.setPageContext(pageContext);
    handler.sendImage(media);
    This code works fine and the image displays on the browser, but only in Internet Explorer or Safari. When I try to retrieve the image using Firefox, the browser wants to download the image instead of displaying it. The downloaded image has the extension ".jsp". The downloaded file however, is a valid jpg-image because if I change the extension to ".jpg" I can view the image in any image viewer software.
    Does anybody know how to make this work?
    Markus

    I have no problem on OC4J and the following JSP....
    (Needs a photo table, and a URL of the form:
    http://<SERVER>:8888/examples/jsp/ExampleMediaDelivery.jsp?id=1
    Did you do a handler.setPageContent?
    <%@ page language="java" %>
    <%@ page import="oracle.ord.im.OrdHttpJspResponseHandler" %>
    <%@ page import="oracle.ord.im.OrdImage" %>
    <%@ page import="oracle.ord.im.OrdMediaUtil" %>
    <%@ page import="oracle.jdbc.pool.OracleConnectionPoolDataSource" %>
    <%@ page import="oracle.jdbc.pool.OraclePooledConnection" %>
    <%@ page import="oracle.jdbc.driver.OracleConnection" %>
    <%@ page import="oracle.jdbc.OraclePreparedStatement" %>
    <%@ page import="oracle.jdbc.OracleResultSet" %>
    <jsp:useBean id="handler" scope="page"
    class="oracle.ord.im.OrdHttpJspResponseHandler"/>
    <%
    // Get ID of image to fetch. We could get other parameters as well
    boolean imageSent = false;
    String id = request.getParameter( "id" );
    if ( id != null && !"".equals(id) )
    // Use a try block to ensure the JDBC connection is released
    OracleConnection conn = null;
    try
    // Get a connection from the pool. The SQL would be better done
    // from a factory....
    javax.naming.InitialContext ic = new javax.naming.InitialContext();
    OracleConnectionPoolDataSource ds = (OracleConnectionPoolDataSource)
    ic.lookup("jdbc/pool/OracleMediaPoolDS");
    OraclePooledConnection pc = (OraclePooledConnection)
    ds.getPooledConnection();
    conn = (OracleConnection)pc.getConnection();
    // Here, we go to the database and populate album with an image
    // from the database, Returns null if image not found or
    // image column is null (not populated).
    String imgSelectSQL = "select image from photos where id = " + id;
    OraclePreparedStatement stmt = (OraclePreparedStatement)
    conn.prepareStatement(imgSelectSQL);
    OracleResultSet rset = (OracleResultSet)stmt.executeQuery();
    rset.next();
    OrdImage imageProxy =
    (OrdImage)rset.getORAData("image", OrdImage.getORADataFactory());
    rset.close();
    if ( imageProxy == null)
    response.setStatus( response.SC_NOT_FOUND );
    return;
    // Send this image.
    handler.setPageContext( pageContext );
    handler.sendImage( imageProxy );
    imageSent = true;
    finally
    // Ensure the JDBC connection is released
    if (conn != null) conn.close();
    // Go to not found error
    if (imageSent) return;
    %>
    <%-- The request does not include a key to the row --%>
    <html lang="EN"><head><title>ExampleMediaDelivery.jsp - malformed URL</title></head>
    <body><h1>ExampleMediaDelivery.jsp - malformed URL</h1>
    </body></html>

  • Send image to browser with cfcontent not download prompt

    I'm sending an image to be downloaded using cfcontent
    <cfheader name="Content-disposition" value="attachment;filename=#getit.file#">
    <cfcontent type="image/jpg" file="#physicalpath#\#getit.file#">
    Can I have the image sent to the browser instead of a download prompt?

    If the image isn't accessible directly via HTTP, you can use CF to serve it. Your CF page would have the CFCONTENT tag as you showed in your original post, then you'd use IMG tags in other pages pointing to that CF page:
    <img src="myimage.cfm?id=whatever"/>
    You wouldn't need the CFHEADER to specify it as an attachment, though - that's only for when you want to prompt the user to download a file without having it handled natively by the browser.
    Dave Watts, CTO, Fig Leaf Software
    http://www.figleaf.com/
    http://training.figleaf.com/

  • Showing various images on browser using JSP and Servlet

    Hello Guys!
    I am starting to develop in Java and already I am facing a big problem.
    If somebody will have some tip or suggestion, will be very well comings!
    The application must present in browser images originnally of format TIF. As it is not a native format of the I.E. , I converted the image for JPG (without saving it on disk) and send it to the browser a encoded image (encode) using JAI library in one servlet had access by a JSP. Then, the structure of my application is thus:
    1) an archive JSP draws the initial screen in browser and presents one input text.
    2) later that the user places the parameter, I make an access to the database and read a quantity of images to be presented.
    3) From there in the proper JSP, I use de tag img src to send image to the browser in agreement archive the amount of images.
    It follows the code of the JSP:
    <% 
                    int intI=0;
                    int intCont=0;
                    if(blnImagem == true){
                        out.println("<br>");
                        out.println("<table border=0 STYLE=border-collapse:collapse>");
                        out.println("<tr>");
                        for(intI=0;intI < Processo.intQtdImagens;intI++){
                           Imagem.strImgTif = Imagem.IndicarImagem(Processo.strNmPath,Processo.strSubPath,Processo.intNuImagem,intI);                                                                    
                           out.println("<th>");
                           out.println("<table border=1 STYLE=border-collapse:collapse rules='cols'>");
                           out.println("<tr>");
                           out.println("<th>");
                           %>
                             <img src="ShowImg" WIDTH=100>
                           <%
                           out.println("</th>");
                           out.println("</tr>");
                           out.println("</table>");
    %>and code on the ShowImg servlet:
            response.setContentType("image/jpeg");       
            ServletOutputStream sos = response.getOutputStream();
            RenderedOp src = JAI.create("fileload", Imagem.strImgTif);           
            ImageEncoder encoder = ImageCodec.createImageEncoder("JPEG",sos,null);       
            encoder.encode(src); 
            sos.close();The problem is if I have 10 images to present, it WILL BE it is executed 10 times and it passes 10 names of different archives, but in the page only the last image is presented 10 times. It is as if it processed the TAG to the end of everything in way that the value of the static variable Imagem.strImgTif was chore only with the last value and the same loaded image 10 times. How I make to solve this? Somebody has some idea?
    THANK YOU !
    Emidio

    If I understand correctly what your problem is:
    Do this in the jsp:
    out.println("<img src=\"ShowImg?image=" + intI + "\" WIDTH=100>");
    In the image servlet, get the "image" parameter and parse it as an int. Move the Imagem.IndicarImagem() call to the image servlet.

  • Sending Audio to Browser - Performance issue

    Hi,
    I have written a simple jsp page that retrieves an OrdAudio object from the database and sends it to the browser. I have done this before with images, which worked perfectly. For the audio files, I simply changed the image specific code to work with audio.
    The problem is that for an approximately 100KB audio file, it takes a good two minutes for it to play in the browser. Over a broadband connection this seems pretty slow. Is there a way to improve this?
    here is part of my code:
    // create OrdAudio instance
    OrdAudio media = (OrdAudio)result.getCustomDatum(1, OrdAudio.getFactory());
    // set page context and send audio to browser
    handler.setPageContext(pageContext);
    handler.sendAudio(media);

    This doesn't sound right. One thing that caught me eye is that you are measuring the time that the audio "plays in the browser." Is there any chance that this 100kb file has a 100sec audio duration? How long should it take to play this audio file?
    One way to debug is to change the mid-tier logic to save the file to the local disk instead of sending it back on the HTTP response. You can use the method getDataInFile(java.lang.String filename) where filename is a string representing the full path to a local fiel that you have permission to write to. If you time this call, you can measure how long it takes to fetch the data from the database.
    The other issue concerns the client side HTML coding. What are you coding to accept the audio data? Browsers accept images (JPEG and GIF) natively but plugins are required to accept audio data. How is this being handled?

  • Displaying Tiff Image on browser

    Hi friends ,
    I want to display tiff image on browser . For that i have written one servlet witch will desplay tiff image on browser
    Here i am sending my code snippets for servlet.
    Here file is source file which i want to display.
    FileSeekableStream ss = new FileSeekableStream(file);
              ImageDecoder tiffDecoder= ImageCodec.createImageDecoder("tiff", ss, null);;
              p = tiffDecoder.getNumPages();
              for(int x=0;x<p;x++){
              RenderedImage tiffPage = tiffDecoder.decodeAsRenderedImage(x);
              ByteArrayOutputStream stream = new ByteArrayOutputStream();
         TIFFEncodeParam tiffOptions = new TIFFEncodeParam();
         // You may want to set compression or tile attributes on the     EncodeParam here
         RenderedOp l_return = JAI.create("encode", tiffPage, stream,"TIFF", tiffOptions);
         bt = stream.toByteArray();
    then writing this byte array(bt)
    OutputStream out;
    out.write(bt);
    and responce .setContentType("image/tiff");
    i also want to know whether mime type image/tiff is supported or not in servlet.
    When i run servlet i am getting File Downloading dialog box.
    also when i download image file it's size is very large than original.
    Plz correct my code.It's verry urgent.
    Thanks in Advance

    hi, could you post the solution?
    I'm looking forward to know the solution.
    Thanks

  • Sending images over network socket

    I'm working on a java web server. So far i have managed to get it to send html documents sucessfully to the client web browser, using a BufferedReader, and a PrintWriter object.
    But how should i send images over the socket? using this method doesn't work. Any suggestions?
    Thanks in advance.
    hornetau

    I did it first. You may pay me $10 and get XM2 WebServer 1.2 from my company.
    Ok, I'll help ya out here...
    HTTP protocol in Internet Explorer is "juiced up" meaning that it does not require HTTP data to be correctly sent. To send an image to be deisplayed...
    <html>
    <img src="theImage.gif"></img>
    </html>
    Now, the server will see a GET request like this...
    GET /theImage.gif HTTP/1.1
    Accepts: Image/jpeg, Image/gif, ...
    Your web server (in the IE case just needs to send)...
    output.println(data);
    The data object is a string, that represents the contents of the image.
    To do that, just get the correct File object, connect reader to it, then loop it
    until the reader is no longer ready (reader.ready() != true), as it loops, just append
    the readLine() command to the end of the data string and it will be ok.
    Now this works on IE just fine, using vary small file sizes due to it being loaded directly into
    memory. Casing problem if your app has only 500K of memory and the file size is 700K, 500-700=-200K, so use only small file sizes with this method.
    There is also the URLConnection and HttpURLConnection classes to use that will do this better, but
    they dont have any real way of getting the file's data - that's still YOUR job.

  • Can't Send Images

    For the past week or so I haven't been able to send images from skype. Sending mp3 files and documents works fine, but when I try to send a picture it's stuck on the sending image thumbnail (as the picture in the attachment)
    I've read a lot of post about this in the past few days, but I haven't found anything on this particular issue.Any help would be appreciated, thanks.

    ruwim wrote:
    Try again to reset all Internet Explorer settings: http://support.microsoft.com/kb/923737 Next reset LAN settings: Open Internet Explorer. Go to Tools -> Internet Options -> Connections -> LAN settings. Make sure that the only option selected is “Automatically detect settings”. Next clear all Temporary Internet Files: Open Internet Explorer -> Tools -> Internet Options -> General. In the section “Browsing history” press the “Settings” button and in the next window the “View files” button. Delete all files from the Temporary Internet Files folder. I've tried all of those steps, but it still isn't working.

  • "Rend Error" when sending image via iChat/AIM

    On my brand new iMac aluminum, I am unable to send, and friends are unable to send, images via iChat AIM 3.1.8 (V445). When either of us try to send, we get the message "An undefined AIM error has occured. The server message was: Rend: Error"
    I then spin around and use my old G4 iMac to send an image - no problem. My buddy is also able to send to me, no problem.
    Both computers are connected to the same Linksys WRT54G router. When I searched for the term 'rend' only one thread came back which suggested to change the port from 5190 to 443. I did this and it didn't help.
    Any other suggestions?

    Hi Craig,
    In the Linksys set up pages you have Application and Gaming (Which is where I think you are talking about)
    In there there are several options.
    Port Forwarding, Port Triggering, DMZ (possibly UPnP Forwarding and QoS)
    Disable any Port Forwarding or Port Triggering. DO not use the DMZ.
    Save settings. (you should still have Web browsing and Mail abilities).
    GO to the Administration tab on the top row.
    Enable UPnP.
    Save Settings.
    UPnP allows multiple computers to use the same ports.
    This way the Linksys can be left doing DHCP if you wish and it will not matter if your computer gets a new IP every now and then. Also the Ports are opened by the application and close after a timed period of non use.
    You can limit the "Hops" to the number of devices the computer is from the Linksys (1 ?) to make it more secure.
    On the main set up page you could limit the the DHCP range to the number of computers you have to prevent outside connections.
    The ports you describe so far are only the TExt chatting and file sending ports
    11:23 AM Monday; August 13, 2007

  • Problem in sending images in Email

    Hi,
         I am unable to send images in Email.
    My template jsp is as :-
    <img src='<%=getServletContext().getRealPath("/images/logo.jpg")'%>
    In Email its not displaying .
    Please help..
    Thanks

    <img src='<%=getServletContext().getRealPath("/images/logo.jpg")'%>
    Above code is not displaying image coz when browser is rendering email content, It's expecting logo.jps to be present in image directory relative to browser temporary folder, Which is not..
    If u wan to display image in mail, U have two options:
    Either attach image in mail as suggested by Prateek.
    Make Image url a absolute url.
    Usually Sites send email with absolute ur, When u read email, ur browser gets the image and render the content along with image.
    Thanks,
    Nitin.

  • Error: Unable to locate an image file browser...

    I get the error below when I insert an image element and try to associate a picture to it by either double clicking it or using the browse button in the Draw palette.
    I have looked in my install directory and the "FileSystemBrowser.dll" file is present as well as the "ImageFileBrowserIDL.dll" file, so what gives?
    Running LiveCycle ES2 9.0.0.2.20120627.2.874785

    Hi,
    you should be able to fix that problem by re-registering Designer file browser DLL.
    http://thelivecycle.blogspot.de/2014/02/diy-bugfix-image-file-browser.html

  • Double clicking an image in Browser view

    I see that the behavior for double clicking an image in Browser view has changed between Aperture 2 & 3. In version 2, double clicking an image would jump from Browser view to zoom in on that image in full screen mode. Now in version 3, double clicking just switches to that image in Viewer mode in the main window, without entering into full screen mode.
    While I guess this change makes some sense given the changes to full screen mode in v.3, my old fingers have gotten used to doing things the old way. To recreate what I used to do in v.2 I need to double click, then hit 'F' to do to full screen mode and then do the reverse to get back where I started.
    Is there anyway I can change this behavior to the old v.2 way? I see lots of ways to customize hotkeys and commands, but nothing to change behaviors for a double click.
    Thanks!

    I can't find anything, but I'm still finding my way around!
    I don't think you need to double click and press F..... just pressing F should change views.
    Another way is to drag the "Full Screen" icon into the toolbar, and you can just click that.

  • How to send image file through mail without   any attachment

    Plz tell  me how to send image file through mail without any attachment  ( i mean not converting  that image into pdf or any format )  i want to send that text or image  through mail .

    Hi Sandeep,
    I think you can setup the type of email in Shared office Settings in transaction S016.
    There is an option called <Preset document classes>
    You choose this pushbutton to branch to the maintenance screen for the document classes that are directly displayed to users in the Business Workplace for selection when they use the Create function. The name under which the documents are displayed can also be maintained.
    http://help.sap.com/saphelp_nw70/helpdata/en/6c/69c30f418d11d1896e0000e8322d00/content.htm
    Haven't tried it though.
    Regards,
    Siddhesh

  • How to send images using SOAP adapter

    hi All,
    I want to send images using the SOAP adapter . ( Sender and Receiver )
    Can anybody help out with this requirement
    Regards,
    Loveena

    Hi,
    Following links may help U
    /people/siva.maranani/blog/2005/09/03/invoke-webservices-using-sapxi
    http://help.sap.com/saphelp_nw04/helpdata/en/3c/b4a6490a08cd41a8c91759c3d2f401/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/29/5bd93f130f9215e10000000a155106/frameset.htm
    to know the basics about soap adapter u cn check out this link
    /people/padmankumar.sahoo/blog/2005/02/15/an-overview-of-soap
    to get in detail about the attachments chk out this link
    hi i am unable to attach an attachment in File to mail scenario
    Regards
    Pullarao

  • How to send images through PI using SOAP adapter

    hi,
    Can anybody tell me how to send images through PI using SOAP adapter.
    Regards ,
    Loveena

    Hi Loveena,
    only as attachments of a SOAP message.
    Regards,
    Udo

Maybe you are looking for