Display a PDF in a web architecture

All interested Flex developers,
I was asked to post this entire issue to Flex forum.
Flash Web applications cannot directly display PDF images (unlike PNG, JPEG, GIF images).
Our network architecture is:
user browser <---- Flex web app <---- SOAP/WSDL protocol <---- backend PDF file server
The Flex web app receives a Base64 PDF and decodes to a ByteArray[]
A) Can anyone map a PDF ByteArry to JPEG or PNG?
B) Can we write a temporary file.PDF in the web server?
Then we could display the temporary file using a web iFrame.
C) Does someone have a neat idea to display a PDF in our web apps without prompting the user?
thanks,
Medical Flash developers

I agree that option A would be a pretty intensize task to map PDF bytes to bitmap bytes.
For option B,  there's a good post here about how you can upload a bytearray by loading the data manually into a FileReference: http://www.pavlasek.sk/devel/?p=10.  He even gives some code for a Java servlet that will accept the ByteArray.
-Mike
ramblingdeveloper.com

Similar Messages

  • Can you link to specific start and end pages of pdf in a web page

    I'm using iframes to display a pdf on a web page. i want to be able to link to for example pages 2-3 of a 20page document.
    I know i can link to a start page or a bookmark/destination but i only want those 2-3pages available to the viewer not the whole document.
    Is this possible?

    Not without a server-side application that extracts those pages as a new
    file and opens it instead of the original.

  • How do I get the Adobe toolbar to display above a pdf in the web browser?

    Hi guys,
    I'm just having trouble with locating the grey toolbar, it's not displaying when I open a .pdf in a web browser.
    I can open the .pdf fine, (within Safari), and usually (on my old computer) there was a grey toolbar above the .pdf & there's a print icon on it - that's what I'm looking for, so that I can print my lecture notes straight away.
    The toolbar won't display on the web browser above the .pdf, but if I save the .pdf & open it with Adobe Reader, then the toolbar displays there with all of the icons etc.
    So I was wanting to know if instead of saving them every time, if there's an option to get the toolbar displaying above .pdfs in Safari?
    Has anyone else encountered this problem?
    Any help would be greatly appreciated.

    Unfortunately, iOS does not provide a way to install "plugins" to Safari so there is no possible way the Reader can do this. You can use the "open in" functionality to launch Reader from Safari.

  • Display PDF document in web browser

    Hi,
    I have a smartform which is being triggered from Web UI. I got the data and converted it to PDF format.
    I need to display this PDF data in a web browser Pop up.
    Please let me know how can I do that.
    Thanks
    Abhishek

    Abhishek,
    If you are using the business transaction types, you can setup a default "print" action which then when you click on the "print preview" in the webUI you will get an PDF output view of the print output.
    If that doesn't work, then look at the business partner factsheet code delivered by SAP which will show how to display a PDF.
    Look at component/view BP_HEAD/BPHEADOverview
    Class CL_BP_HEAD_BPHEADOVERVIEW_IMPL
    method IF_BSP_WD_TOOLBARR_CALLBACK~GET_BUTTONS
    and this section of code
          IF lr_partner IS BOUND AND lv_enabled = abap_true.
            lr_partner->get_property_as_value( EXPORTING iv_attr_name = 'BP_GUID'"#EC NOTEXT
                                               IMPORTING ev_result    = lv_partner_guid ).
            IF lv_partner_guid IS NOT INITIAL.
    *       ICF handler class prepares java script
              CALL METHOD cl_crm_afs_print=>get_url
                EXPORTING
                  iv_object   = lv_object
                  iv_key      = lv_partner_guid
                  iv_role     = lv_business_role
                  iv_language = sy-langu
                  iv_form     = ' '     "read from customizing
                  iv_format   = lv_format
                IMPORTING
                  ev_url      = lv_url.
              IF lv_url IS INITIAL.
                lv_enabled = abap_false.
              ELSE.
                lr_cuco_head ?= get_custom_controller( 'BP_HEAD/Lifecycle' )."#EC NOTEXT
                IF lr_cuco_head IS BOUND.
    *              CONCATENATE '"' lv_url '"' INTO lr_cuco_head->gv_preview_url.
                  lr_cuco_head->gv_preview_url = lv_url.
                ENDIF.
              ENDIF.
            ENDIF.
            ls_button-text  = cl_wd_utilities=>get_otr_text_by_alias( 'CRM_UIU_BP/BP_PDF' )."#EC NOTEXT
            ls_button-tooltip  = cl_wd_utilities=>get_otr_text_by_alias( 'CRM_UIU_BP/BP_FS_PREVIEW' )."#EC NOTEXT
    *        ls_button-on_click = 'PREVIEW'.
            ls_button-on_client_click = 'OpenPopUp()'.          "#EC NOTEXT
            ls_button-page_id  = me->component_id.
            ls_button-enabled = lv_enabled.
            ls_button-icon_src = '/sap/bc/bsp/sap/crm_ppm/w_pdf__s.gif' ."#EC NOTEXT
            APPEND ls_button TO rt_buttons.
            CLEAR ls_button.
          ENDIF.
        ENDIF.
      ENDIF.
    Good luck,
    Stephen

  • Display a PDF returned as a base64 encoded clob from web service

    I'm trying to display a PDF document returned from a SOAP v1.1 web service. I'm able to return the XML into a collection using a process of type 'web service', but am struggling to display the document.
    This is the code I'm using to (attempt to) display the document, which doesn't return anything. If I exclude the clobbase642blob conversion an Adobe Reader pop-up appears, but I get an error message stating it is not a supported file type or the file has been damaged, which I would expect since it's a clob rather than a blob.
    DECLARE
      l_length    NUMBER;
      l_file_name VARCHAR2 (4000);
      l_file CLOB;
      l_blobfile BLOB;    
      l_ext VARCHAR2 (4000);
    BEGIN
      SELECT xtab."fileContent", xtab."fileName"
      INTO l_file, l_file_name
      FROM apex_collections c,
              XMLTable(XMLNAMESPACES(DEFAULT 'http://www.stellent.com/Payslip_Services/'),'//Payslip_Get_FileResponse/Payslip_Get_FileResult/downloadFile' passing xmltype001
                COLUMNS "fileContent" clob PATH 'fileContent'
                      , "fileName" PATH 'fileName'
              ) xtab
    where c.collection_name = 'P15_PAYSLIP_GET_FILE_RESULTS';
    l_blobfile := apex_web_service.clobbase642blob(l_file);
    l_length := DBMS_LOB.getlength(l_file);
      If INSTR (l_file_name, '.', -1, 1) > 0 then
          l_ext := SUBSTR (l_file_name, INSTR (l_file_name, '.', -1, 1) + 1);
      End if;
      IF (UPPER (l_ext) = 'PDF') THEN
        OWA_UTIL.mime_header ('application/pdf', FALSE);
      ELSIF (UPPER (l_ext) = 'DOC') THEN
        OWA_UTIL.mime_header ('application/msword', FALSE);
      ELSIF (UPPER (l_ext) = 'TXT') THEN
        OWA_UTIL.mime_header ('text/plain', FALSE);
      ELSIF (UPPER (l_ext) = 'HTML') THEN
        OWA_UTIL.mime_header ('text/html', FALSE);
      ELSE
        owa_util.mime_header('application/octet', FALSE );
      END IF;
      HTP.p ('Content-length: ' || l_length);
      HTP.p ( 'Content-Disposition: attachment; filename="' || l_file_name || '"' );
      OWA_UTIL.http_header_close;
      WPG_DOCLOAD.download_file (l_file);
    END;
    Apex 4.2.2
    Oracle 11g 11.2.0.1.0
    Any suggestions would be appreciated.
    Thanks,
    Graham

    What Adobe product is this a question for? This forum is for XML/API functionality for Adobe Connect. I'll move this question to the appropriate forum.

  • AdobeAcrobat/Reader that is running can not be used to view PDF Files in Web Browser...what do I need to do to fix this..

    I just got Windows 7 and have been having problems since loading it. Most of my drivers only go to Vista and don't recognize 7.
    I have trying to download some manuals from their website
    and keep getting this message; Adobe Acrobat/reader that is running can not be used to view PDF files in Web Browser.

    Could I suggest a workaround for PDFs until a solution is posted? Open them directly in the Adobe application rather than in a browser tab.
    In your Adobe application(s), go to:
    Edit > Preferences > Internet
    Then uncheck "Display PDF in browser"
    (There are very few sites where having PDF integrated is really beneficial.)

  • Adobe Acrobat/Reader can not be used to view PDF's in Web browser.

    Does any one came accross the following message trying to view PDF's in web browser? "Adobe Acrobat/Reader that is running can not be used to view PDF documents in Web browser. Please exit the Acrobat?Reader application and try again". Thanks for your help! Barbara

    http://helpx.adobe.com/acrobat/using/display-pdf-browser-acrobat-xi.html

  • How do I get the PDF Convert feature of Adobe Acrobat Pro Extended 9.4.4, which makes a PDF of a web page interactive, to work in Firefox 4.0.1?

    I just installed (on my Windows 7 Ultimate (64 bit) operating system/Intel i5 CPU M560 2.67 GHz) and am now using as my default browser Firefox 4.0.1 because Internet Explorer 9 was giving me so much trouble--lack of display of web content, lack of PDF reproduction when web content displayed, screwball formatting display, etc., all of which has been remedied by the mere installation of Firefox 4.0.1.
    How do I get the PDF Convert feature of Adobe Acrobat Pro Extended 9.4.4, which converts a web page to an interactive PDF, to set up and work on Firefox 4.0.1?

    You can not do that using Adobe Acrobat 9. Adobe never made a create PDF add-on for Firefox for use with Adobe Acrobat 9. They created a Firefox add-on for use with Acrobat X, but currently that one does not work with Firefox 4 though Adobe are working on an update.

  • Hyperlinks from Word not correct in pdf when in web browser v7

    We have a table of contents that we we have in word, the word file has hyperlinks to individual PDF files.  After a new item is added to the table on contents, we distill the word to a pdf.  Users access the pdf from a web page.  Recently something changed and the pdf file of the table of contents is not linking to the correct pdf file. 

    Thanks for clarifying that. We hadnt given consideration to the use of signatures like thatr as you have mentioned.
    Can we distribute the document without the risk of losing the signature validity in the Word document ?
    Is it better to apply signatures to PDFs ?
    Or can we preserve the appearance of the signature in the Word document ?
    I wonder why just one of the signatures is not displaying when i use the Adobe menu to generate the PDF.
    Perhaps some setting in the job options is causing that? What might it be though ?

  • How to make a PDF form call Web service and return a static pdf for user to print?

    Hi all,
    Can anyone help me regarding the feasibility of using PDF forms for my following case?
    I would like to create a Dynamic pdf form. User only have the Acrobat reader. they can enter some information. Then have a submit button. when user click the submit button, it can call the web service with data. then Web service returns a Static PDF document based on data and the user can print it out. (and maybe save as separate pdf file)
    1. Is that possible to implement? Because I know PDF can call web service, but dont know how it handle when the webservice returns another static PDF document. could it able to handle the responds and open up in another acrobat reader?
    2. As I understand I need to have Live Cycle Designer to create a pdf  and make it Reader Enabled. So user can user reader to call webservice? am I correct?
    3. What minimum reader that user need to have? PDF reader 7 or above?
    4. I have a webservice serve the same purpose for web. But if I want the same web services can serve both web and PDF form. So, whatever client (PDF or Web)make the web service call, server returns the PDF document to client. Is that possible ? Do I need to make any changes on web service?
    5. Do I need to get any other Adobe server product? (other than Live Cycle Designer )
    Thanks a lot

    We have done a similar approach in the past and yes, it can be doable.
    1. Is that possible to implement? Because I know PDF can call web service, but dont know how it handle when the webservice returns another static PDF document. could it able to handle the responds and open up in another acrobat reader?
    Srini: We have developed a Servlet to talk to Webservice. Based on the Webservice response, the Servlet, prepares the Byte stream and sends it to Webbrowser to display as a PDF. The PDF data was submitted to Servlet in XML format.
    But if you do not want to use the above approach, then you have to use the Workbench Process.
    Submit the PDF data to a Workbench process and the inside process, execute Webservice Service with the data. Once the response is received, prepare the data XML and render a PDF with it.
    To do this, you need LiveCycle Server and Reader Extensions server component.
    2. As I understand I need to have Live Cycle Designer to create a pdf  and make it Reader Enabled. So user can user reader to call webservice? am I correct?
    Srini: If you want to use the Servlet, you can Reader extend the PDF with Acrobat.. But if you want to submit the data directly to Webservice, then you need Reader Extensions server component.
    3. What minimum reader that user need to have? PDF reader 7 or above?
    Srini: Not sure but Reader 8 and above should work.
    4. I have a webservice serve the same purpose for web. But if I want the same web services can serve both web and PDF form. So, whatever client (PDF or Web)make the web service call, server returns the PDF document to client. Is that possible ? Do I need to make any changes on web service?
    Srini: If you use the Servlet approach, then you can re-use the same webservice. But if you want to submit directly to the same webservice, you may need to change it to suit your data XML.
    5. Do I need to get any other Adobe server product? (other than Live Cycle Designer )
    Srini: If you use the Servlet approach, you do not need any server component but other approach, you need Livecycle Server and Reader Extensions server component.
    Thanks
    Srini

  • How do I open a pdf on a web page in Safari without Acrobat Reader?

    At the moment I have removed Acrobat Reader 10.3.1 because it conflicts with Safari. Preview is a perfectly fine pdf reader (and with lots of very nice features) but I don't see how I can make Preview open a pdf from a web page until it has been downloaded to file. And I have found at least one site that will not download to file before opening.

    Right-click in the PDF when it's displayed in Safari and select Open with Preview from the popup menu. Depending on how the PDF is embedded in the web page, this may not be possible.

  • Cannot open a PDF on the web due to end user agreement problem

    I own Acrobat 9. I recently installed my work version of acrobat CS5.5 at home. I want to read a PDF on the web. I just went thru this with live chat. Can someone please solve this problem. This is what I just wasted 15 minutes on:
    Thank you for choosing Adobe. A representative will be with you shortly. Your estimated wait time is 0 minute(s) and 3 second(s) or longer as there are 1 customer(s) in line ahead of you.
    You are now chatting with 'Raghu'
    Raghu: Hello. Welcome to Adobe Technical Support.
    Raghu: Hi Stephanie.
    stephanie: Hello can you please solve my problem
    Raghu: Yes, I'll be glad to assist you with the issue.
    Raghu: I understand that you are unable to open PDF because of  enduser agreement pops up.
    stephanie: I'm waiting
    Raghu: Am I correct ?
    stephanie: yes
    Raghu: Okay, can I have the serial number for Acrobat please ?
    stephanie: where is it?
    Raghu: The serial number is on the reverse side of the CD-ROM/DVD-ROM disc case or on a sticker on the CD/DVD sleeve.
    Raghu: If you had purchased the product from Adobe You will find the serial number on the order confirmation e-mail from Adobe Store and in your Adobe account as well.
    stephanie: That's at work.
    stephanie: I have acrobat 9 serial number. This is taking a lot of t5ime already. I just want to read a pdf on the web
    Raghu: I certainly understand your concern.
    Raghu: I'll certainly assist you.
    stephanie: Will you just solve the problem NOW
    Raghu: However I need to verify for the valid serial number for Acrobat from our customers.
    stephanie:xxxed out correct serial number
    Raghu: Please launch Acrobat X.
    stephanie: absolute power corupts absolutely
    stephanie: It is launched
    Raghu: Then click on 'Edit'.
    Raghu: Then select 'Preferences'.
    Raghu: Select 'Internet' from the list.
    stephanie: preferences is under axcrobat not edit
    Raghu: I understand you are using Acrobat X.
    stephanie: yes
    Raghu: You will find 'Preferences' under ;Edit'.
    stephanie: I ahve internet selected under preferences
    Raghu: Do you see the option 'Display PDF in browser' ?
    stephanie: Not under internett
    Raghu: When you click on 'Internet', on the right side panel on the same window you will see 'Display PDF in browser' .
    stephanie: It's grayed out
    Raghu: 'Allow fast web view' is selected ?
    stephanie: yes if I uncheck it nothing happens
    Raghu: I'm sorry to hear that Stephanie .
    Raghu: I'll provide you the link for the forums.
    stephanie: solve the problem
    Raghu: Please refer forums regarding this.
    Raghu: The serial number you provided me is not a valid serial number.
    stephanie: There is no help on the forums. I need to read a PDF NOW!!!!!!!
    stephanie: I told you it's a serial number for acrobat 9 that doesn't work either
    Raghu: You can read the PDF using Adobe Reader.
    Raghu: Please go ahead and install Adobe Reader.
    Raghu: I'll provide you the link to install Reader.
    stephanie: Your're insane. I want to use acrobat SOLVE THE PROBLEM NOW
    Raghu: Stephanie, please be informed that this is a professional chat. We can not assist the customer without the valid serial number.
    stephanie: I gave you a serial num,ber that is vgalid for acrobat 9. I wabnt to use it to read a pdf on the web.
    Raghu: Please contact us again with serial number for Acrobat X.
    Raghu: I understand your concern. However the serial  number you provided me is not a valid serial number.
    stephanie: xxxed out correct serial number is a valid number. I own it.
    Raghu: Yes this is a valid serial number for 'Design premium CS4'.
    Raghu: Earlier you provided xxxed out correct serial number
    stephanie: Yes. I want to read a PDF in Acrobat 9 which I own. SOLVE THE PROBLEM
    stephanie: I'm posting this entire dialong on adobe forums now
    Raghu: Stephanie, I see that the serial number is for CS4.
    Raghu: Support for this product is available only at Support portal and user forums.
    stephanie: I told you that. I want to use it. SOLVE THE PROBLEM
    Raghu: I would request to refer to our  Support portal and user forums for more information on this.
    Raghu: However, you can try reinstalling the product and check if it works.
    Raghu: I can understand your concern, however, the product is out of our support.
    stephanie: According to adobe forums that doesn't work.
    This is completely ludicrous.

    Your posting somewhat confused me.
    It sounds like you have two versions of Acrobat installed. You say you own Acrobat 9. You also say you installed a version of Acrobat  CS 5.5. Does that mean you installed the Adobe Creative Suite 5.5 on your computer as well? There is no such product as  Acrobat CS5.5. CS5.5 would install Acrobat X.
    However, if you had installed CS55 you may have to open at least one of the other CS5.5 applications before you can open Acrobat X. That's because Acrobat X is not well integrated into the Creative Suite.
    Am I understanding your situation?

  • Error when displaying a pdf file in an iFrame

    Hi,
    I would like to display a pdf file in my Java Web Dynpro application. I am using an iFrame element.
    The code I used is:
    // test if the file exists
    if( path != null)
         path = "D:\\Echanges\\Facture\\" + path + ".pdf";
    if (isFile(path)) // test if the file exist
         wdContext.currentContextElement().setPath(path); // we set the path of the file for the iFrame url
    else
         wdContext.currentContextElement().setPath("D:\\Echanges\\errorDocAccess.htm"); // here we set the path of an error file to display in the iFrame
    In the context, path is declared as a String variable and mapped to an iFrame. What happen when I lauch the program is the followig error:
    com.sap.tc.webdynpro.services.exceptions.InvalidUrlRuntimeException: Invalid URL=D:/Echanges/errorDocAccess.htm
    I have checked the path of the error file and it is valid. How do I get to display my file ? The path is on the same server as the portal.
    Thanks a lot for your help.
    Thibault Schalck

    Not solved

  • Using IFRAME in JSF to display a PDF file

    2 all,
    How do i display a PDF file inside a JSF page in a IFRAME tag?
    I store the PDF file location (like d:\images\pdf1.pdf) in my database. I cant give this location directly into the src attribute cos then the file will be rendered to only users who have access to that folder (the application is a internet application). IFRAME would be ideal as the display is very very neat (esp for pdf files).
    To get this working i tried the examples given in balusc blogs (on image servlet) but the problem is that my servlet is not getting called. Find below the web.xml and imageDisplay.jsp pages that i tried
    web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>WorkFlowTool</display-name>
    <context-param>
      <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
      <param-value>server</param-value>
    </context-param>
    <filter>
      <filter-name>MyFacesExtensionsFilter</filter-name>
      <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
      <init-param>
       <param-name>maxFileSize</param-name>
       <param-value>20m</param-value>
      </init-param>
    </filter>
    <filter>
      <display-name>SecurityCheckFilter</display-name>
      <filter-name>SecurityCheckFilter</filter-name>
      <filter-class>filters.SecurityCheckFilter</filter-class>
    </filter>
    <filter-mapping>
      <filter-name>MyFacesExtensionsFilter</filter-name>
      <url-pattern>/faces/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
      <filter-name>MyFacesExtensionsFilter</filter-name>
      <url-pattern>*.faces</url-pattern>
    </filter-mapping>
    <filter-mapping>
      <filter-name>MyFacesExtensionsFilter</filter-name>
      <url-pattern>*.jsf</url-pattern>
    </filter-mapping>
    <filter-mapping>
      <filter-name>SecurityCheckFilter</filter-name>
      <url-pattern>/faces/*</url-pattern>
    </filter-mapping>
    <listener>
      <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
    </listener>
    <servlet>
      <servlet-name>Faces Servlet</servlet-name>
      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
      <servlet-name>Image Servlet</servlet-name>
      <servlet-class>servlets.ImageServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
      <servlet-name>Image Servlet</servlet-name>
      <url-pattern>/imageServlet/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
      <servlet-name>Faces Servlet</servlet-name>
      <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
      <servlet-name>Faces Servlet</servlet-name>
      <url-pattern>*.faces</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
      <servlet-name>Faces Servlet</servlet-name>
      <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    <session-config>
      <session-timeout>60</session-timeout>
    </session-config>
    <welcome-file-list>
      <welcome-file>/jsp/index.jsp</welcome-file>
    </welcome-file-list>
    <error-page>
      <error-code>500</error-code>
      <location>/jsp/error.jsp</location>
    </error-page>
    <resource-ref>
      <res-ref-name>jdbc/JDDS</res-ref-name>
      <res-type>java.lang.Object</res-type>
      <res-auth>Container</res-auth>
      <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
    </web-app>
    imageDisplay.jsp
    <HTML>
    <HEAD>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%>
    <f:loadBundle basename="messages" var="msg" />
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <LINK rel="stylesheet" type="text/css" href="../theme/Styles.css"
         title="Style">
    </HEAD>
    <body topmargin="0" leftmargin="0">
    <f:view>
         <h:form id="CaseLookUp">
              <h:dataTable value="#{pc_ImageDisplay.dataModel}" var="var">
                   <h:column id="one">
                        <f:facet name="header">
                             <h:outputText value="H1" id="HOne"/>
                        </f:facet>
                        <h:outputText value="#{var.caseID}" id="IDONE"/>
                   </h:column>
                   <h:column id="two">
                        <f:facet name="header">
                             <h:outputText value="H2" id="HTwo"/>
                        </f:facet>
                        <h:graphicImage value="imageServlet?file=#{var.PODocPath}" id="image"/>
                   </h:column>
              </h:dataTable>
         </h:form>
    </f:view>
    </body>
    </HTML>The image servlet is what i got from balusc's site (http://balusc.blogspot.com/2007/04/imageservlet.html).
    I dont know why my servlet is not getting called. Can someone help me with this pls?
    okay let me post the modified code for my image servlet here
    public class ImageServlet extends HttpServlet {
         private static final long serialVersionUID = 1L;
         public void doGet(HttpServletRequest request, HttpServletResponse response) {
            // Define base path somehow. You can define it as init-param of the servlet.
    //        String imageFilePath = "/images";
            // In a Windows environment with the Applicationserver running on the
            // c: volume, the above path is exactly the same as "c:\images".
            // In UNIX, it is just straightforward "/images".
            // If you have stored images in the WebContent of a WAR, for example in the
            // "/WEB-INF/images" folder, then you can retrieve the absolute path by:
            // String imageFilePath = getServletContext().getRealPath("/WEB-INF/images");
            // Get file name from request.
            String imageFileName = request.getParameter("file");
            System.out.println("Inside the image servlet ---->>>> " + imageFileName);
            // Check if file name is supplied to the request.
    //        if (imageFileName != null) {
    //            // Strip "../" and "..\" (avoid directory sniffing by hackers!).
    //            imageFileName = imageFileName.replaceAll("\\.+(\\\\|/)", "");
    //        } else {
    //            // Do your thing if the file name is not supplied to the request.
    //            // Throw an exception, or show default/warning image, or just ignore it.
    //            return;
            // Prepare file object.
            File imageFile = new File(imageFileName);
            // Check if file actually exists in filesystem.
            if (!imageFile.exists()) {
                // Do your thing if the file appears to be non-existing.
                // Throw an exception, or show default/warning image, or just ignore it.
                return;
            // Get content type by filename.
            String contentType = URLConnection.guessContentTypeFromName(imageFileName);
            // Check if file is actually an image (avoid download of other files by hackers!).
            // For all content types, see: http://www.w3schools.com/media/media_mimeref.asp
            if (contentType == null || !contentType.startsWith("image")) {
                // Do your thing if the file appears not being a real image.
                // Throw an exception, or show default/warning image, or just ignore it.
                return;
            // Prepare streams.
            BufferedInputStream input = null;
            BufferedOutputStream output = null;
            try {
                // Open image file.
                input = new BufferedInputStream(new FileInputStream(imageFile));
                int contentLength = input.available();
                // Init servlet response.
                response.reset();
                response.setContentLength(contentLength);
                response.setContentType(contentType);
                response.setHeader(
                    "Content-disposition", "inline; filename=\"" + imageFileName + "\"");
                output = new BufferedOutputStream(response.getOutputStream());
                // Write file contents to response.
                while (contentLength-- > 0) {
                    output.write(input.read());
                // Finalize task.
                output.flush();
            } catch (IOException e) {
                // Something went wrong?
                e.printStackTrace();
            } finally {
                // Gently close streams.
                if (input != null) {
                    try {
                        input.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                        // This is a serious error. Do more than just printing a trace.
                if (output != null) {
                    try {
                        output.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                        // This is a serious error. Do more than just printing a trace.
        }

    Thanks Balusc!!
    I have made use of your code to display PDF files in an IFRAME tag too!!! I just dint believe that this would be possible. Please just take a look at my JSP page.
    <h:form id="CaseLookUp">
         <%
         String path = request.getContextPath()+"";
         out.print(path);
         %>
    <iframe scrolling="auto" src="<%=path%>/imageServlet?file=D:\70-229 V5.pdf" width="80%" height="600" ></iframe>
         </h:form>

  • Edit error message as displayed when browsers fail to display dynamic pdfs

    I'm sure many people here are aware of the problems that arise when many browsers attempt to open a dynamic writable pdf. The built in plugin that ships with most browsers is unable to display the content, and as a result the following message is shown.
    "If this message is not eventually replaced by the proper contents of the document, your PDF viewer may not be able to display this type of document. You can upgrade to the latest version of Adobe Reader for Windows®, Mac, or Linux® by visiting http://www.adobe.com/go/reader_download.
    For more assistance with Adobe Reader visit http://www.adobe.com/go/acrreader."
    (I trimmed a bit because the message is quite long)
    My question is, is there some way to modify the message above by editing the pdf using a program like Adobe Livecycle or Acrobat Pro? The message that displays is basically useless, because the problem is actually due to the browser's inability to display the pdf. If it is possible to replace this message with something more meaningful, such as instructions on downloading the form with right click, that would be fantastic for the users.
    Does anyone know where this information is stored? It doesn't seem to be browser specific (as the browsers I've tested seem to display the same message).

    I got the error messages to work from properties file and some helper class, but not through just defining in faces-config or web.xml.
    I am sure there is a better way to do but hopefully this will help you.
    FacesContext context = FacesContext.getCurrentInstance();
    In my validation method - I have the following code, which will associate
    the appropriate message
    String failureMsg = ErrorMessages.getString("SignUpData.NO_USER_NAME");
    FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,          failureMsg, failureMsg);
    context.addMessage("login_form:username", message);     
    My properties file - errormessage.properties - have the following info
    SignUpData.NO_USER_NAME =Please Enter User Name
    SignUpData.NO_PASSWORD =Please Enter Password
    Helper class - ErrorMessages.java
    import java.util.MissingResourceException;
    import java.util.ResourceBundle;
    public class ErrorMessages {
    private static final String BUNDLE_NAME = "com.path1.path2.resources.error_messages";
    private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
    private ErrorMessages() {
    public static String getString(String key) {
    try {
    return RESOURCE_BUNDLE.getString(key);
    } catch (MissingResourceException e) {               return '!' + key + '!';
    I am also looking for a way to avoid all this extra helper classes if there is a better alternative.
    thanks
    ponni

Maybe you are looking for