Servlet runs twice at PDF Stream

I made a servlet that post a PDF file. I see the servlet run twice when I invok it just once.
That happens only on pdf files, I try wdith gif an jpeg files and runs fine.
tanks
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
InputStream in = null;
OutputStream out = null;
try {
System.out.println("get PDF file");
response.reset();
out = response.getOutputStream();
response.setContentType("application/pdf");
in = new BufferedInputStream( new FileInputStream("file.pdf"));
int ch;
while ( (ch = in.read()) != -1 ) {
out.write( (char)ch );
catch (Exception e) {
e.printStackTrace();
finally {
if( in != null ) {
in.close();
if( out != null ) {
out.flush();
out.close();
}

I ran across this problem last month. The problem only occurs in Internet Explorer. Netscape runs fine. It used to be that Internet Explorer sent three separate requests in order to receive an in-line pdf. I ended up just having to code around it.

Similar Messages

  • Response processing time causing pdf streaming issue

    My servlet invokes JasperReports to generate streamed pdfs. One report has a lengthy processing time due to 5 second delay from complex stored procedure. Is the length of time to process this request causing my response to fail? Is there a setting to allow certain time for the request to process? Thanks.

    That depends on the client. An average webbrowser will timeout the request after 30~60 seconds. This is catchable on the server side when OutputStream#close() throws an IOException (which is in case of for example Tomcat subclassed as ClientAbortException).
    If it gets really that long, consider firing a new thread to process the long running process and return some page which fires repeated requests for "status update" until it is finished. In old times you could do that with a meta refresh header, but nowadays you can do that nicely with ajaxical stuff.

  • DocClose event runs twice after extending with user rights

    I have created a form with several fields. To check if the fields are filled, I have placed several checks if the DocClose event. This creates a messagebox containing text of the missing fields. This will only popup when the pdf is closed. See below for a part of the Java-script.
    var errmsg = ""
    if (Form.Page1.CompanyName.rawValue == null)
    {errmsg = errmsg + "CompanyName is not filled in";}
    if (Form.Page1.CompanyStreet.rawValue == null)
    {errmsg = errmsg + "\n";
    errmsg = errmsg + "CompanyStreet is not filled in";}
    if (errmsg !== "")
    {xfa.host.messagebox (errmsg, "Please note!",1,0);}
    else
    This works just fine in Adobe Acrobat and in Adobe Reader. However,the user needs to be able to save a local copy. So, I use Adobe Acrobat 9 Standard to "Extend Forms Fill-In & Save in Adobe Reader". After this change, when this PDF is opened in the Reader or in Acrobat, the messagebox runs twice! The first time as it should, but the second time, it
    I also noticed that the Script language of this part has changed from Java to mixed.
    Thanks for any help!
    Erik

    Dear all,
    I have the same problem, do you have any solution for this?
    Best regards
    Fernando

  • Working with pdf streams (UIX/Struts)

    I have a pdf stream that I would like to display to the user, I'm using ADF/UIX/Struts.
    I generate the stream in the application module via custom method, and would like a "Download" and "View" link on the page.
    Has anyone done anything similar? How should I go about this?
    Many thanks

    You might have to implement your own PageRenderer (oracle.cabo.servlet.PageRenderer) for this purpose.
    If you have abstracted the pdf as a file or InputStream/Reader, the existing implementation in oracle.cabo.servlet.util.FileDownloadRenderer should be useful.
    Javadocs (from UIX reference help topic in JDeveloper) should provide further information about these interface/class.

  • Adobe reader 7 hangs, task manager shows it is running twice

    I am using Adobe Reader 7
    I have a problem, when I click on a ,pdf file it opens but it is locked, if I try to zoom or do anything else it freezes up, I check in task manager and it shows that AR is running twice, if I oen a pdf and leave it, and dont zoom or do anything else after about a 2 minutes it will work fine,
    anybody know a fix for this?
    I have unistalled and reinstalled tried different versions etc, but nothing works.
    TIA

    Yes it runs twice, if I let it go for about 2 minutes and do not touch it or try to do anything with it, it will start to work and it will only show up once in the task manager, however if I open it and try to scroll, zoom, or even close it, it will freeze completely.

  • CRS 2008 Scheduled Report Runs Twice

    All,
    I have been using CRS 2008 for about 6 months now and have had scheduled reports running since the beginning. Last month I created new schedules for each report and deleted the old schedule. However, although the old schedule no longer shows in the History tab, it appears to still be running. As of right now, I have only one schedule per report, however, each report gets processed and saved out twice. This did not start happening until I created new schedules and deleted the old ones.
    Is there something else I have to do (or can do) in order to completely remove the old schedules or fix the new ones if that happens to be the issue?
    Thanks,
    Tom

    Fritz,
    Each report (of which there are 9 at this point), is set up in the following manner:
    1. Scheduled to run once a day (times staggered by 5 minutes for each starting at 12:15am)
    2. 6 are delivered to a folder on the network, 3 are delivered via email
    3. All have the same naming structure: InstanceTitle_DateTime.FileExt
    4. Each are formated as PDF
    Originally, the six that are delievered to a network folder were also delivered via email as well. This issue only started happening after I deleted those email deliveries. Also, the 3 that are still delivered via email and have never been modified after first being set up are now being run twice as well.
    After looking in the network folder this morning, it appears that only four of the six were run twice last night, while all six were run twice for the two nights before that.
    This is very frustrating since I have already deleted and started from scratch and still have this issue. Any help would be greatly appreciated. Thanks.

  • Oracle report on web running twice

    I have got a problem with reports. Reports are being run on iexplorer. Same report is running fine on clint server. It's also running fine with Win 2000 professional. But when it is run on Win XP prof, the report runs twice & all the report triggers fire twice.
    Resultant is after report clears all the date from temp table & when the final report comes it doesn't show any data.
    Please suggest what can be the cause for this.

    PDF format, right?
    In IE, go to Tools, Internet Options and then under Temporary Internet Files, click Settings. Make sure the "Check for newer versions of stored pages:" is set to Automatically.
    If that isn't it, upgrade/downgrade the XP machine to use the same version of Adobe as the Win2K machine.
    IE has had this problem with printing for a long time.
    Try using a ref cursor in your report rather than a temp table.

  • JSP runs twice for 1 request.

    Can anyone explain why after a single request to this page there is two hashes on the commandline? This is running on Java 1.5 with Tomcat 5 and using Apache xerces and xalan.
    <%@ page
        language="Java"
        import="java.io.*, java.util.*, javax.xml.transform.*,
    javax.xml.transform.stream.*"
    %>
    <%
       File xml = new File(this.getServletContext().getRealPath(""), "menu.xml");
       File xsl = new File(this.getServletContext().getRealPath(""), "menu.xsl");
       TransformerFactory factory = TransformerFactory.newInstance();
        StreamSource stylesheet = new StreamSource(xsl.toString());
        Transformer transformer = factory.newTransformer(stylesheet);
        StreamSource source = new StreamSource(xml.toString());
        StreamResult result =
            new StreamResult(out);
        transformer.transform(source, result);
        System.out.println("#");
    %>

    Simple browser call to the jsp page using Mozilla Firefox. I haven't actually tried Internet Explorer or another browser yet.
    I have tried writing the xml output to a StringWriter instead of the JSPWriter named out and this seems to make the page run only 1, but as soon as I write out the HTML rendered from the XML it runs twice.
    This is very perplexing...

  • Stored Proc running twice using DBMS_Scheduler

    Hello all,
    I have a vb front end that calls a main stored proc which submits scheduler jobs to execute several stored procs asynchronously. Everything is working, except the part that the several stored procs are running twice. In the troubleshooting, I have eliminated the front end from being the culprit and the stored procs themselves. Essentially, when I call the stored proc using dbms_scheduler.create_job, it runs twice, even manually. I am about at wits end trying to figure out why: Using Oracle 11gR2
    I started off setting up the programs
    begin
    --create program
    dbms_scheduler.create_program
    ( program_name => 'prog_name'
    ,program_type => 'STORED_PROCEDURE'
    ,program_action => 'usp_sub_proc_1'
    ,number_of_arguments => 8
    ,enabled => FALSE
    dbms_scheduler.DEFINE_PROGRAM_ARGUMENT
    ( program_name=> 'prog_name'
    ,argument_position=>1
    ,argument_name => 'name'
    ,argument_type=>'VARCHAR2'
    /*the remaining 7 arguments are in code but not display for space reasons*/
    dbms_scheduler.enable('prog_name');
    end;Then the main stored proc executes this code:
    declare v_job_name varchar2(100);
        v_1 varchar(50) := 'All';
        v_2 varchar(50) := 'All';
        v_3 varchar(50) := 'All';
        v_4 varchar(50) := 'All';
        v_5 varchar(50) := 'TEST';
        i_6 integer := 1;
        v_7 varchar(50) := 'TEST_NE';
        ts_8 timestamp := current_timestamp;
    begin
        v_job_name := 'uj_dmo_1';
    dbms_scheduler.create_job (v_job_name
                                            ,program_name => 'prog_name'
                                            ,job_class => 'UCLASS_1'
                                            ,auto_drop => TRUE
    --set parameters
    dbms_scheduler.set_job_argument_value(v_job_name,1, v_1);
    dbms_scheduler.set_job_argument_value(v_job_name,2, v_2);
    dbms_scheduler.set_job_argument_value(v_job_name,3, v_3);
    dbms_scheduler.set_job_argument_value(v_job_name,4, v_4);
    dbms_scheduler.set_job_argument_value(v_job_name,5, v_5);
    dbms_scheduler.set_job_argument_value(v_job_name,6, to_char(i_6));
    dbms_scheduler.set_job_argument_value(v_job_name,7, v_7);
    dbms_scheduler.set_job_argument_value(v_job_name ,8, to_char(ts_8));
    --enable job
    dbms_scheduler.enable(v_job_name);
    --execute job
    dbms_scheduler.run_job(job_name => v_job_name , use_current_session => FALSE);
    end;
    ...And this is where I get the double execution of the job, but I am just not seeing it in my syntax, dba_scheduler_jobs, logging, etc. Any help is greatly appreciated, thanks!!

    Well apparently I will not win any Captain Obvious awards;
    With 34MCA2K2's response with "what doesn't work" for some reason turned the light on. After some more testing here is what I found.
    This code works as expected :
    Exhibit A
    begin
    dbms_scheduler.create_job (job_name =>'TESTER'
                                   ,job_type => 'PLSQL_BLOCK'
                                   ,job_action => 'declare test1 integer := 1; begin test1 := test1 + 5; end;'
                                   ,auto_drop => True
       /*dbms_scheduler.enable('TESTER');   */
       dbms_scheduler.run_job(job_name => 'TESTER', use_current_session =>FALSE);   
    end;As does this:
    Exhibit B
    begin
    dbms_scheduler.create_job (job_name =>'TESTER'
                                   ,job_type => 'PLSQL_BLOCK'
                                   ,job_action => 'declare test1 integer := 1; begin test1 := test1 + 5; end;'
                                   ,auto_drop => True
       dbms_scheduler.enable('TESTER');  
      /*dbms_scheduler.run_job(job_name => 'TESTER', use_current_session =>FALSE);    */
    end;Exhibit A will create the job and is visible in the schedulerjobs view, and the RUN_JOB will execute it even when not enabled, but the pl/sql will not drop the job.
    Exhibit B will create the job and once enabled, executes the job and then drops from schedulerjobs view.
    Therefore, my desired results for running the jobs once asynchronously and dropping immediately is....
    begin
        v_job_name := 'uj_dmo_1';
    dbms_scheduler.create_job (v_job_name
                                            ,program_name => 'prog_name'
                                            ,job_class => 'UCLASS_1'
                                            ,auto_drop => TRUE
    --set parameters
    dbms_scheduler.set_job_argument_value(v_job_name,1, v_1);
    dbms_scheduler.set_job_argument_value(v_job_name,2, v_2);
    dbms_scheduler.set_job_argument_value(v_job_name,3, v_3);
    dbms_scheduler.set_job_argument_value(v_job_name,4, v_4);
    dbms_scheduler.set_job_argument_value(v_job_name,5, v_5);
    dbms_scheduler.set_job_argument_value(v_job_name,6, to_char(i_6));
    dbms_scheduler.set_job_argument_value(v_job_name,7, v_7);
    dbms_scheduler.set_job_argument_value(v_job_name ,8, to_char(ts_8));
    /*enable job*/
    dbms_scheduler.enable(v_job_name);
    /*execute job (Do not execute the code below, it will lead to multiple executions)
    dbms_scheduler.run_job(job_name => v_job_name , use_current_session => FALSE); */
    end;

  • I have a php module which runs fine in Firefox and all other browsers but not Safari. It always run twice - I see a small ? in upper right corner which is causing it to run twice but NO idea why? Help - thank you

    I have a php module which runs fine in Firefox and all other browsers but not Safari. It always run twice - I see a small ? in upper right corner which is causing it to run twice but NO idea why? I read it MAY have something to do with am image it cannot load but I see them all loaded.  Help - thank you

    Could you share a link to the page?
    Seeing it in context and in our browsers is much easier to debug.
    If not, make sure to run the validator here The W3C Markup Validation Service and clear out any problems. HTML errors, especially structural ones, will cause all kinds of display problems in various browsers/versions/platforms.

  • How to schedule a job to run twice within a request set?

    How to schedule a job to run twice within a request set?

    Create one more stage for the same concurrent program.
    Thanks
    Nagamohan

  • DBMS scheduler jobs running twice

    Hi,
    I have 4 DBMS scheduler jobs , which checks for a specific job status in DB and sends an email , when i started the schedule for the first week the jobs executed fine from next week I am getting two emails from each job , when i check the logs USER_SCHEDULER_JOB_RUN_DETAILS I see only one run , which seems weird to me so i disabled one job and left the three jobs in schedule , next time i got two emails from 3 jobs and one from disabled job . After checking logs i see that there is no entry of the disabled job execution . I am not sure where is the problem i can't find any log from where the disabled job executing. Please help me
    Job schedule is to run every Saturday
    Interval setup :
    start_date => trunc(SYSDATE)+ 8.5/24,
    repeat_interval => 'TRUNC(LEAST(NEXT_DAY(SYSDATE,''SATURDAY'') )) + 8.5/24'
    Suresh

    Hi,
    I tried to schedule the same jobs using DBMS_JOB but i still get the same problem , I created the procedure with all code in and scheduled it using dbms job , first day it run once second day it run twice ( sending two emails) Inow i am not sure if issue is with my code or scheduler
    Procedure
    Declare
    v_count number;
    v_Recipient VARCHAR2(400) := '[email protected]';
    v_Subject VARCHAR2(80) := 'TEST_Email';
    v_Mail_Host VARCHAR2(30) := 'localhost';
    v_Mail_Conn utl_smtp.Connection;
    crlf VARCHAR2(2) := chr(13)||chr(10);
    BEGIN
    select count(*) into v_count from TEC_CODERETURN@RPRD where interface like 'FOR002B' and trunc(rundate) =trunc(sysdate);
    if v_count = 0
    then
    v_Mail_Conn := utl_smtp.Open_Connection(v_Mail_Host, 25);
    utl_smtp.Rcpt(v_Mail_Conn, '[email protected]');
    UTL_SMTP.OPEN_DATA(v_Mail_Conn);
    utl_smtp.WRITE_RAW_DATA(v_Mail_Conn, UTL_RAW.CAST_TO_RAW(
    'Date: ' || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || UTL_TCP.CRLF ||
    'From: ' || '[email protected]' || UTL_TCP.CRLF ||
    'Subject: '|| v_Subject || UTL_TCP.CRLF ||
    'To: ' || v_Recipient || UTL_TCP.CRLF ||
    'This is a test Alert'|| UTL_TCP.CRLF
    UTL_SMTP.CLOSE_DATA(v_mail_conn);
    utl_smtp.Quit(v_mail_conn);
    end if;
    EXCEPTION
    WHEN utl_smtp.Transient_Error OR utl_smtp.Permanent_Error then
    raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
    END;
    DBMS job creation
    DECLARE
    jobno NUMBER;
    BEGIN
    DBMS_JOB.submit
    (job => jobno,
    what => 'TEST_ALERT;',
    next_date => trunc(sysdate)+0.1/24,
    interval => 'SYSDATE + 1',
    no_parse => TRUE );
    DBMS_OUTPUT.put_line ('Created Job - the job number is:' || TO_CHAR (jobno));
    COMMIT;
    END;
    Suresh

  • Use servlet to open a PDF at a specific page

    Is it possible to create a servlet to open a PDF file at a specific page?
    The equivalent of myPdf.pdf#page=12 but through a servelt using header of the response may be?

    This is easier solved outside of Acrobat. For example, if your clients download the PDF from a website, add a form with the text and an "I agree" button before you provide them the link to the file. Or if you send it to them by email, first send them an email to which they need to reply before getting the PDF.

  • Empty sqaures[] in exported pdf stream - crystal api

    Hello,
    Web application using - CR4E version 2.0.16
    Reports design using Crystal Reports 2013
    I am exporting crystal report into pdf file format using crystal java api that gets shipped with Crystal reports for eclipse. The exported pdf stream returned by the api is saved in db as blob so that it can be viewed/sent to printer later. If I view the pdf blob saved in db using acrobat reader I can see the pdf is correct.
    But when I stream blob data directly to printer using java print service for print jobs and PDFRenderer.jar for PDF print pages, the output is empty sqaure blocks []. All the formatting is intact. I can also see number of rows.
    This seems to be the problem for exported pdf's from crystal api's or even if you manually export the pdf from crystal report and save the pdf file from file system in the db.
    Other PDF files work fine but not the ones exported from Crystal report.
    The font properties of the rpt exported pdf shows the encoding as 'Built-in' while the other pdf files has ANSI or other such encodings. That is the only difference I find between pdfs exported from Crystal and other pdf files.
    Can you please tell me how to resolve this?
    Best Regards,
    Bharat

    Hi Manas,
    I am also working on Exporting Crystal report to PDF  in java but facing some problem in accessing the database.
    The .rpt files are published in Crystal Report Server with DB info like server, database, user, password.
    When i am calling from java (Similar to your code), its giving error like JNDI name not found. But i am not using any JNDI binding.
    Do i need to configure database details in any configuration files such as CRConfig.xml etc. If yes, can you pass me some sample code.
    Your help highly appreciated.
    Thanks
    VK

  • Why the process chain always run twice when triggered from R3?

    I run a program from R3 by calling the remote function 'RSSM_EVENT_RAISE' on BW to trigger an event and in turn the event on BW bring up the running of a process chain.  But whenever I run the program on R3 to bring up the running of the process chain, I find the process chain always run twice at the same time.  Does anybody knows the answer? 
    And also I would like to know the functionalities of the two picture buttons "Activate" and "Activate and Schedule" in process chain.  In which case the "Activate" button should be used and in which case, the "Activate and Schedule" button should be used?   If we click the Start variant of a process chain, then click "Change Selections" button which bring up the window "Start Time" where the buttons "Immediate", "Date/Time", "After job", and "After event" are listed at the top.  If we modify at any of the above buttons, then after save this modification, we will have to click "Activate and Schedule" button to make it work, right? 
    Thanks a lot and everyone's idea is greatly appreciated!

    Kevin, make sure there is only one job scehduled for the Start Process of your Process Chain.  If you bring up the Process Chain (not the log view), right click on the Start Process and select "Displaying Scheduled Job(s)...".  There should only be one scheduled job with name BI_PROCESS_TRIGGER.  If there is more than one, then when triggered, it would execute more than once at the same time.  If there is only one job, then maybe your R/3 program is triggering the event more than once? 
    As far as the Start conditions for the Start Process, it works off the same principals as a scheduled job.  These start conditions determine when or how the Process Chain is to be executed.  You also have control over frequency.  These start conditions determine the scheduling of the Start Process of your Process Chain.
    When you schedule a Process Chain, a separate scheduled job is created for "each" process in the Chain.  BW controls the triggering of these jobs based upon how the processes in the Chain are linked.  All the jobs associated with Process Chains have strict naming conventions and all begin with BI_PROCESS_...  If you use SM37 to view all jobs that begin with BI_PROCESS_ you will find alot of scheduled jobs associated with your process chains.  Each job represents one of the processes within your process chains. 
    Does this help?
    Another tip might be to trigger the event manually in BW (use tx SM64).  If the process chain executes twice again, then maybe there is a separate scheduled job in BW that triggers the process chain that is triggered by the same event as the start process of the process chain.
    Message was edited by: George Shannon

Maybe you are looking for

  • Differences in appearance when using a Mac vs. PC

    www.thecampuscocktail.com I used a PC to create the site, however I asked my roommate to test it on his Mac and the menu seems to have 2 rows on his computer. As is the width is too small? Before I went around changing my CSS I was going to ask if an

  • Can't activate iTunes Match or Genius Error -3000

    ENGLISH I can not activate genius or match itunes, I get error -3000 that was after upgrading to version 10.7.0.21 before was perfect, in fact I have already deleted all libraries and even I uninstalled and reinstalled and the problem persists , I ha

  • IPhoto will not open - says: Library created with unreleased version

    I can't even open the app. due to a message that reads "The photo library was created with an unreleased version of iPhoto. Please quit and update this photo library by opening it in iPhoto 2 or iPhoto 4." I haven't done anything to the library recen

  • MS word 2011 and Lion 10.7.2

    Dear All, After updating to Lion 10.7.2, I have encountered this error message when trying to save files in MS Word to my own hard drive. This happens after a couple of minutes use. 'You cannot save while the file is in use by another process. Try sa

  • VDI 3.0 with Patch2 - Virtual Box 2.0.10 - Host Networking

    Hi Guys, I have got following setup at a customer site: Solaris 10 U7 : Sun VDI 3 Server NIC0 - 192.168.100.xx network - sun vdi3.0 All-in-one configuration is installed here NIC1 - 192.168.34.xx network - windows xp template is bound to this NIC (br