How to Open PDF in the browser...JSF

String strUrl = http://..../xxxxxe43cb072378947fe8c1b7bcc7201691a.pdf
FacesContext faces = FacesContext.getCurrentInstance();
ExternalContext context = faces.getExternalContext();
HttpServletResponse response = (HttpServletResponse)context.getResponse();
response.sendRedirect(strURl);          Hello,
I have to open PDF in the browser, I am trying to redirect using the above code, but it is throwing exception as below. Could some one help me in this issue?
Thanks In advance
Error Message:
java.lang.IllegalStateException: Cannot forward after response has been committed
Error details:
java.lang.IllegalStateException: Cannot forward after response has been committed
     at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:313)
     at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
     at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
     at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
     at com.esri.adf.web.faces.application.ADFViewHandler.renderView(Unknown Source)
     at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
     at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
     at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
     at com.esri.adf.web.util.ADFSessionTimeoutFilter.doFilter(Unknown Source)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
     at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
     at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
     at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
     at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
     at java.lang.Thread.run(Unknown Source)

You cannot send two responses per request. The solution is to let the client create two requests. Common approach is to add an onclick to the commandbutton/commandlink which opens the PDF in a new browser window and let the actual command action invoke a redirect on the current browser window.
E.g.<h:commandLink value="Download PDF" action="#{myBean.action}" onclick="window.open('http://..../xxxxxe43cb072378947fe8c1b7bcc7201691a.pdf');" />where the #{myBean.action} invokes a redirect and the http://..../xxxxxe43cb072378947fe8c1b7bcc7201691a.pdf opens the PDF in the new window.
Edit
I've read your question/problem once more and now I am a bit confused. All you want to do is to open the PDF file in a new window and you don't need to do something in the backing bean? Just use a link with target="_blank".
<h:outputLink value="http://..../xxxxxe43cb072378947fe8c1b7bcc7201691a.pdf" target="_blank">Download PDF</h:outputLink>No need for a redirect here.
Edited by: BalusC on Nov 21, 2007 7:21 AM

Similar Messages

  • How to open pdf files in browser using flex

    hi,
    my project is having a Document explorer wchich contains pdf
    files,iwant to open it in the browser.can any one tell me how to
    open pdf documents using flex programming(i tried with different
    thing like swf's but my client wants only pdf formatt).

    Another option is by calling a JSP page. This example will
    open a pdf file into a new browser without displaying the download
    "save" prompt.
    Function to call the JSP:
    private function downloadFlyer(event:Event):void {
    var jspLink:URLRequest = new
    URLRequest("jsp/downloadpdf.jsp?fileName=Fundraiser_flyer_2008.pdf");
    navigateToURL( jspLink, "_blank" );
    JSP code:
    <%@ page errorPage="error.jsp" %>
    <%@ page import="java.io.*" %>
    <%
    //Get the parameters
    String downloadFileName=request.getParameter("fileName");
    String fileName = application.getRealPath("/downloads/" +
    downloadFileName);
    File file = new File(fileName);
    if (!file.exists()) {
    throw new IOException("File does not exist.");
    // Get the size of the file
    long length = file.length();
    // You cannot create an array using a long type.
    // It needs to be an int type.
    // Before converting to an int type, check
    // to ensure that file is not larger than Integer.MAX_VALUE.
    if (length > Integer.MAX_VALUE) {
    throw new IOException("File too big.");
    response.reset();
    response.resetBuffer();
    response.setContentType( "application/pdf" );
    response.setHeader ("Content-Disposition", "filename=" +
    downloadFileName);
    //Prevent the Java error: "getOutputStream() has already
    been called for this response"
    out.clear();
    out = pageContext.pushBody();
    InputStream in = new FileInputStream(file);
    OutputStream output = response.getOutputStream();
    try {
    int curByte=-1;
    while( (curByte=in.read()) !=-1){
    output.write(curByte);
    } catch (IOException ioe) {
    ioe.printStackTrace(System.out);
    } finally{
    output.flush();
    in.close();
    response.flushBuffer();
    %>

  • How to open report in the browser from PL/SQL procedure

    Hi,
    I need to call the report (with destype = SCREEN) from the PL/SQL procedure and display in the browser.
    For Example: when I call P_call_report procedure in my Forms6i button or at sql*plus, the report output PDF/HTML should open in the Browser window.
    Iam Using IE, report6i, forms 6i, Oracle 8.1.7, Windows OS
    I tried using UTL_HTTP(' ') in a procedure. But when I execute the procedure at sql*plus it says Pl/sql procedure completed successfully message without opening report output in the browser window. If I copy the same url and paste it in the browser, it works.
    Please let me know if there is any solution.
    thanks alot.

    I guess event driven publishing may work. But Iam not sure about the opening of the browser from inside the procedure.

  • I have Adobe Reader in stalled on my MacBook Pro but the plugin is not showing in FireFox so I am unable to open pdf's in browser. How can I correct?

    When I encounter a site that requires me to fill in a pdf form the browser opens in Adobe Reader and not in the browser. I have checked off in Adobe Reader to open pdf's in browser but it still will not.

    I do not think adobe reader works as a plugin for Firefox on Macs, ( but a PC user myself so I can not check). See [[Installing and updating Adobe Reader]]
    Note specifically comments in the Mac version of that [/kb/Using%20the%20Adobe%20Reader%20plugin%20with%20Firefox?s=pdf+plugin+mac&as=s#os=mac&browser=fx35] about alternative plugins.

  • Open PDF in same browser when the preference is set to open in new window.

    The corporate policy for all applications is to open the PDF document in new browser/reader but our application needs the reader to open in the same browser even the preference "Display PDF in Browser" is unchecked.... The setPreference from javascript (html) doesn't seemed to work... How do i make this work?
    Also, I need the links the browser to open in new browser once the PDF is loaded... do I need to reset the preference once it is loaded for the links to open in new browser?
    thanks,
    - Ray

    There is no way to override that from your application.   And if the Links in the PDF have an explicit "open in new window" setting, that is respected over the preference.
    From: Adobe Forums <[email protected]<mailto:[email protected]>>
    Reply-To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
    Date: Wed, 19 Oct 2011 22:02:53 -0700
    To: Leonard Rosenthol <[email protected]<mailto:[email protected]>>
    Subject: Open PDF in same browser when the preference is set to open in new window.
    Open PDF in same browser when the preference is set to open in new window.
    created by h_ray<http://forums.adobe.com/people/h_ray> in Acrobat SDK - View the full discussion<http://forums.adobe.com/message/3981167#3981167

  • Acrobat does not opens a PDF in the Browser at all times

    Required:
    I need to ensure Acrobat opens a PDF in the Browser at all times, and not have Reader hijack the task.  All fixes for this I have found won’t work as they render Reader inoperable. i.e. uninstalling Reader or denying users to the Reader executable AcroRd32.exe
    Situation:
    I have a problem with Adobe Reader and Acrobat Standard 8.2.5.  This is on a Terminal Server 2003 with 10 users.  They require both Acrobat and Reader be accessible due to specific 3rd party applications related to banking software. 
    Problem:
    They must open PDFs in a browser with Acrobat so they may fill the forms and save them.  Acrobat doesn’t consistently open the file; Reader hijacks the file when clicked to open and their ability to fill the forms is hindered. 
    -    Open PDF in browser is checked in Acrobat
    -    Open PDF in browser is NOT checked in Reader
    Sometimes when the Acrobat desktop icon is clicked, Reader opens instead.  Having Acrobat open in the background does help but is not consistent.
    Also uninstalling Reader from the Server is unacceptable due to a 3rd party banking application for loans.  This application is hard coded to open AcroRd32.exe within the application for opening PDFs. 
    Any suggestions would be greatly appreciated.
    Ken

    Try this, when I right clicked on the document to rotate the image a noticed a tool bar appeared at the bottom of the page with the save icon. It then disappeared, but by hovering at near the bottom of the document the tool bar appears and I can save the PDF.

  • How to open *.pdf files in BOXI r2 inbox

    I am scheduling as  *.pdf file for deski report.After scheduling i am getting *.pdf in my inbox.if the report is deski or webi we can use FC_REPORT_ENGINE or WI_REPORT_ENGINE to open the report's using java code.In same way how to open *.PDF file in Inbox?
    Edited by: ramkishore kishore on Nov 7, 2008 8:31 AM
    Edited by: ramkishore kishore on Nov 7, 2008 8:31 AM

    Hi Ram,
    Following information might help you to resolve the issue.
    After logging into Desktop Intelligence, you may be presented with a message stating:
    u201CYou have received 1 document from users"
    Examining the Inbox from within the Desktop Intelligence client shows no objects visible in your Inbox.
    The object in your Inbox is in a format other than Desktop Intelligence format such as, PDF, XLS or other format. Therefore the object is not recognized by the Desktop Intelligence client inbox browser.
    Log in to Info View or the Central Management Console, browse to your Inbox and verify the file name and format that has been sent to your Inbox. The object may be saved, copied, moved or deleted as necessary.
    Regards,
    Sarbhjeet Kaur

  • How to open PDFs in Safari 8.0

    Been frustrated for a couple days now. Up until mid last week, I've been able to open PDFs inside the safari browser no problem.  I think this ended up changing in the latest Yosemite update.  Opening PDFs inside the safari window, not in a different tab is particularly crucial for my job, I use an agent webportal that requires PDFs to be filled out inside the browser window and submitted as such.
    I've had this happen a few times, usually it was fixed by deleting the adobe plugins in the internet plugins folder and/or simply resetting the safari browser back to default. What I've tried so far:
    uninstalling/reinstalling both reader and acrobat multiple times.
    deleting the plugins from the internet folder multiple times.
    tried switching up the default pdf view app, no change.
    tried as best as i could find to reset the settings on safari, but inside yosemite there appears to not be a reset option to bring it back to default.
    Honestly I'm at my wits end here with this thing. I've been using VMWare and windows 7 to complete the stuff I can't do in safari on IE.
    Is there something I haven't tried and/or does anyone know how to fully reset safari back to default in yosemite?
    specs - MBA 2011, Running 10.10.1. Using newest version of reader and acrobat 10.

    You don't without using custom css sheets. The web site developers specify the fonts to be used.

  • Cant open pdf files in browser

    Cannot open pdf files in browser but can open from hard drive. Using Adobe 11.0.02 with Windows 8. Have uninstalled Reader and reinstalled and then restarted PC; Checked for updates; used the Repair selection on the menu. Frustrated. Suggestions?

    Hi adityabhargava01-
    My first suggestion is to upgrade to the most recent version of Firefox by going to this link:
    http://www.mozilla.org/en-US/firefox/new/
    My second suggestion is to read this article on how to many your preferences on how Firefox deals with PDFs and all other file types:
    [[Options window - Applications panel]]
    I hope that helps!

  • Open PDF-Output in browser window with full height

    Hi,
    I must open some BIP-Reports as PDF in a browser window via URL. The problem ist, that the height of the PDF-Output is fixed, as the PDF is shown in an iframe with fixed height.
    The height can be set in the BIP preferences, but only to a fixed value (not to something like "100%"). If the height is smaller than the users browser window, then there is unused space below the pdf output. If the height is greater than the users browser window, there are two scrollbars to the right: One for the html-Page and one for the PDF.
    I tried the following options:
    1. http://<bip-server:port>/xmlpserver/public/<report-name>.xdo?_xmode=4&_xf=pdf
    -> Output is PDF, only the PDF is shown (_xmode=4), opens in same browser window but height is limited.
    2. http://<bip-server:port>/xmlpserver/public/<report-name>.xdo?_xmode=4&_xf=pdf&_xpt=1
    -> PDF is not opend in browser window, but can be downloaded or opened in a separate PDF-Viewers window.
    I would like to just open the PDF in the browser window in full height. How can I achive this?

    Hello Yesh,
    you can open PDFs as a guest user (without authentification):
    1. Allow Guest Access (Admin -> Security Configuration -> Check "Allow Guest Access" and select a folder name).
    2. Copy your Report into this guest folder
    3. You can open the Report as PDF with a link like this:
    http://(bip-server-name):9704/xmlpserver/(guest-folder-name)/(report-name)/(report-name).xdo?_xpt=0&_xf=pdf&_xmode=4(&report-parameters)
    Just replace the strings in brackets. You find a great description of the URL parameters in Tim Dexters Blog
    http://blogs.oracle.com/xmlpublisher/2006/07/accessing_xmlp_enterprise_repo.html
    I didn't find an option to set the height of the PDF-Output for the guest user in the BIP-UI. Maybe I missed something. But you can manually edit the configuration file. It is located on your BIP server direcory in the subdirectory xmlp/XMLP/Users. Select the guest users subdirectory and edit the configuration file "user~.profile".
    In this XML config file there is an entry "viewerHeight". In the Value-Tag you can enter the PDF output windows height in pixel (but unfortunaly not in % - this was the question of my original posting).
    Hope that helps...
    Sascha
    Edited by: sascha@tesat on Oct 26, 2009 9:02 AM

  • Opening .pdfs in the same window/tab.

    I look at a lot of .pdfs (Journal Articles) in my browse. Generally, I only download a fraction of the ones I look at. Recently, Firefox has stopped opening .pdfs in the same window/tab. Instead, it prompts me to download every .pdf I want to look at. I then have to save them, open them on my desktop, look at them, and then delete the ones I do not want to keep. Does anyone know how to get Firefox 10.0.2 to start opening .pdfs in the same window/tab again?

    Adobe PDF Reader is not on your list of Plug-ins submitted with your question (click on "More system details" to the right of your original question). If it is disabled on the Plug-ins list (''Add-ons > Plugins''), click "Enable". If it is not installed on your system (in your Programs folder), then download the installer and run the installer after it is saved to your hard drive (install with Firefox closed).
    *See --> [https://support.mozilla.org/en-US/kb/Using%20the%20Adobe%20Reader%20plugin%20with%20Firefox#w_installing-and-updating-adobe-reader Installing/Updating Adobe Reader in Firefox] ('''''NOTE:''''' un-check any items on the Adobe download page that you do not want installed on your system)
    *Also see --> [https://support.mozilla.org/en-US/kb/Opening%20PDF%20files%20within%20Firefox Opening PDF files within Firefox]
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''
    Not related to your question, but...
    You may need to update some plug-ins. Check your plug-ins and update as necessary:
    *Plug-in check --> http://www.mozilla.org/en-US/plugincheck/
    *'''''Adobe Shockwave for Director Netscape plug-in''''': [https://support.mozilla.org/en-US/kb/Using%20the%20Shockwave%20plugin%20with%20Firefox#w_installing-shockwave Installing ('''''or Updating''''') the Shockwave plugin with Firefox]
    *Adobe PDF Plug-In For Firefox and Netscape: [https://support.mozilla.org/en-US/kb/Using%20the%20Adobe%20Reader%20plugin%20with%20Firefox#w_installing-and-updating-adobe-reader Installing/Updating Adobe Reader in Firefox]
    *Shockwave Flash (Adobe Flash or Flash): [https://support.mozilla.org/en-US/kb/Managing%20the%20Flash%20plugin#w_updating-flash Updating Flash in Firefox]
    *'''''Next Generation Java Plug-in for Mozilla browsers''''': [https://support.mozilla.org/en-US/kb/Using%20the%20Java%20plugin%20with%20Firefox#w_installing-or-updating-java Installing or Updating Java in Firefox]

  • I have set the CustWiz/MST to 'Disable and Lock' the ability to display PDFs in the browser.  We wan

    I have set the CustWiz/MST to  'Disable and Lock' the ability to display PDFs in the browser.  We want  them to open separately in Acrobat.  After I deploy, the setting IS  disabled and locked, but when you click a PDF in the browser, it STILL  opens in the browser, and not in Acrobat.
    I am pushing  Acrobat onto machines that already have Acrobat Standard 9 installed  with the same settings.  It worked properly then.
    What is causing this setting to be ignored?  How can I fix it?  It's delaying my deployment.
    I have to deploy Acrobat 9 due to the bug I discovered here:
    http://forums.adobe.com/thread/865843
    (With many other frustrating responses).
    This is getting a little irritating...
    Thanks for any input!
    Acrobat Standard X
    XP SP3
    Firefox 5

    Thank you for the answer about updating the Foxit plugin. Firefox tags the Foxit plugin as potentially unstable, so it turns out I had another program killing the plugin's startup process so it was always disabled in firefox. I reenabled its startup process and updated the plugin. To get firefox to use it as the main pdf reader I went to options>applications and changed the option for pdf to the foxit plugin and everything works dandy now! Thanks again!

  • How to open -pdf in a secure environment

    Opening PDF files from a secured account on Internet (e.g. telephone billing info) does not work. in Safe as the file is shown as _pdf (underscore instead of dot).  We suspect this problem started after installing CS6, but are not sure. Win 7, IE 9, Reader XI

    PDF on a regular website can be opened and downloaded. However, PDF on a secure website (https) looks normal with normal icon but double click gives screen for open / save / save as. ‘Open’ gives no result, no error message either. ‘Save’ or ‘save as’ shows screen with filename ending on _pdf, which cannot be opened or saved, no error messages either. Changing the filename into .pdf gives the same reaction: nothing happens, no error messages.
    The same files can be opened on a different PC win7, IE9, Reader XI and similar software, but without CS6.
    Van: Pat Willener [email protected]
    Verzonden: 3 november 2012 5:19
    Aan: EllyHo
    Onderwerp: how to open -pdf in a secure environment
    Re: how to open -pdf in a secure environment
    created by Pat Willener <http://forums.adobe.com/people/pwillener>  in Adobe Reader - View the full discussion <http://forums.adobe.com/message/4820274#4820274

  • Unable to open PDF file in browser using Reader 9 with IE8

    I just updated to IE8 and when trying to open a PDF file on the browser, I received a message stating to use Adobe Reader 8 or 9.  I downloaded AR9 and still receive the same message and cannot open PDF files in browser window.  It defaults to my Adobe Acrobat 6.0 which will not open the file.  I have Windows XP.  I do not have a problem opening a PDF file in Yahoo mail with AR9.  I have tried many different ideas on the web to no avail.  Appreciate any help to be able to default to open PDF files in the browser using AR9 which is apparently required by IE8.

    Fixed problem by taking to a computer store to find that my hard drive storage was maxed out.  I had the hard drive repaced with a larger amount of storage.   Problem resulted from inadequate amount of storage space which prevented me from downloading and installing Adobe Reader 9.
    Thanks to al that responded.  

  • Macbook Air wont's open PDF in Safari browser Version 7.1 (9537.85.10.17.1)

    Hi Guys, can anyone help me out here i bought a new 2014 Macbook Air with a maverick's OS X Version 10.9.5 and it wont's open PDF in Safari browser Version 7.1 (9537.85.10.17.1). I have a adobe reader Version IX 11.0.09
    this is the message i get when i open up a pdf on safari
    To view the full contents of this document, you need a later version of the PDF viewer. You can upgrade to the latest version of Adobe Reader from www.adobe.com/products/acrobat/readstep2.html
    For further support, go to www.adobe.com/support/products/acrreader.html

    i did this is what it says;
    To view the full contents of this document, you need a later version of the PDF viewer. You can upgrade to the latest version of Adobe Reader from www.adobe.com/products/acrobat/readstep2.html
    For further support, go to www.adobe.com/support/products/acrreader.html
    and when i go to my library under internet plug-Ins there's nothing in the file.

Maybe you are looking for

  • How to remove a 3inch CD from the slot loading drive??

    I have am external adapter for various IDE external devices. The drivers came on a 3 inch CD.I put the CD in the slot it did not appear to go all the in and it will not eject using the normal methods. Anyone run into this situation?? Bob

  • Maximum external Hard Drive size for Airport Disk?

    Is there a maximum size for the hard drive that's being connected to the USB port on the new Airport Extremes? Or will it support up to the maximum that's allowed by the USB chipset?

  • Where is TASK manager of MAC

    hey guys, as U know we have a place which called TASK MANAGER in windows operation systems. U can see all the files which are open and U can see CPU RAM HDD and network Usage per second. so Is there any place like this in MAC OS?   if yes plz tell wh

  • Need software that supports video in via USB. QT Pro/iMovie= firewire only

    my friend can upload video from his cam into his pc via the USB but i can't. All I have is Final Cut Pro, iMovie HD and QT7 Pro. They All want firewire. k, i could get a cable but i'd like to save the trip. anything out there? tnx

  • Form builder make an error in windows xp sp2 when connecting oracle xe

    i have installed the forms from developer 6i and tried to connect to oracle xe using form builder , the problem was that windows show an error and it says that an error has occur and we are sorry , do you want to send the message