Servlet generated PDF wont show up in browser

This is the code i use to show the PDF in a browser
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
res.setContentType("application/pdf");
res.setHeader("Content-Disposition","inline;Filename= " + file.getName());
ServletOutputStream sos = res.getOutputStream();
               outStream.writeTo(sos);
               sos.flush();          
               outStream.close();
               sos.close();
In Netscape i get an error saying the filename does not start with %PDF and in IE the page just shows up blank. from the blank pagewhen i use the back button and then hit the forward button the pdf will show up in IE.
I also tries using fileOuput stream instead of servletoutputstream
     FileOutputStream fout = new FileOutputStream( file );
               outStream.writeTo(fout);
               fout.close() ;
               outStream.close() ;
In this case IE does nothing but it works on netscape or mozilla
This is running on websphere 5.0 , apache webserver on linux env
But i need to get this worked on IE any help would be greatly appreciated!
Thanks in Advance
Sid

I just skipped posting over the actual pdf write code.
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
//Write bytes to the PDF
writer = createDocument(document, outStream);
res.setContentType("applicatio�n/pdf");
res.setHeader("Content-Disposi�tion","inline;Filename= " +
file.getName());
ServletOutputStream sos = res.getOutputStream();
outStream.writeTo(sos);
sos.flush();
outStream.close();
sos.close();
If i use fileOutputStream i can see that the file is being created physically without any problem. It would not though open up in the Browser!
Thanks
Sid

Similar Messages

  • Problem opening servlet generated PDF in browser

    This is the code i use to show the PDF in a browser
    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
    res.setContentType("application/pdf");
    res.setHeader("Content-Disposition","inline;Filename= " + file.getName());
    ServletOutputStream sos = res.getOutputStream();
                   outStream.writeTo(sos);
                   sos.flush();          
                   outStream.close();
                   sos.close();
    In Netscape i get an error saying the filename does not start with %PDF and in IE the page just shows up blank. from the blank pagewhen i use the back button and then hit the forward button the pdf will show up in IE.
    I also tries using fileOuput stream instead of servletoutputstream
         FileOutputStream fout = new FileOutputStream( file );
                   outStream.writeTo(fout);
                   fout.close() ;
                   outStream.close() ;
    In this case IE does nothing but it works on netscape or mozilla
    This is running on websphere 5.0 , apache webserver on linux env
    But i need to get this worked on IE any help would be greatly appreciated!
    Thanks in Advance
    Sid

    (SIGH)
    Crossposted over here:
    http://forum.java.sun.com/thread.jspa?threadID=631107

  • Help - Generate pdf files using creator  - plz

    Hello im trying to dynamically generate pdf file and show it on screen but im stuck, i've used itext, but i can make it work, anyone can share his own experience about generating pdf files and viewing on browser at same time using Creator?
    TNKS in advance!

    Hi there,
    Im not sure but the link in this thread might help
    http://forum.sun.com/jive/thread.jspa?forumID=123&threadID=106715
    K

  • Why can't Firefox still not show a pdf properly from within the browser and do we need insufficient and not working add-ons?

    I never succeeded to show a pdf properly in the Firefox browser.
    There is an add-on, but the add-on itself tells you already in most cases that you should download the pdf because it can't show the pdf properly. I can't understand why that is! It makes my live much more complicated, since we have an application running that constantly should be able to show pdf's from within the browser.

    The add-on you are talking about is pdf.js. pdf.js does it best to show you what the pdf's it is given are, but pdf.js is not 100% compatible with all elements that can be put inside a pdf. Another problem pdf.js faces is that many pdf's generated with proprietary software either do not conform to the pdf spec or use proprieatary elements that only pdf readers that the company has designed or partnered with can interpret. I promise you Mozilla doesn't want your life to be any more complicated than it is but sometimes it is simply not possible for pdf.js to read a document when the manufacturer of the program that generated the pdf doesn't play by the rules.

  • I instAlled link gopher 1.3.2 in firefox and it wont show up on my firefox browser so i can use it

    i instAlled link gopher 1.3.2 in firefox and it wont show up on my firefox browser so i can use it. also i can not get any addons to show up. i had downthem all and i got that to to show by clicking view/toolbars/customize and dragging it to my toolbar but even that does not show up and gopher 1.3.2 does not show up in view/toolbars/cuntomize. how can i get these addons to show up?

    This is probably some corruption in the settings file that stores the on-screen position of the Firefox window. Could you try the steps in this thread: [https://support.mozilla.org/en-US/questions/980358 opens off monitor screen]. Any luck?

  • Interactive pdf issue, text wont show up when playing the slidewshow

    I am having a hard time trying to figure out how i can add text on top of am mp4 file and making it work once exported as an interactive pdf. For some reason the mo4 plays fine but the text will not show up. It seems like it will work fine when i look at the swf preview windon in indesign. I can add text a to a page with an im image in the back and that works fine. But not sure why the text wont show up if its an mp4 file instead. anyone have any sugestions?

    havent really worked with buttons on Indesign. But I do recall converting the text into an swf file, and placing it on top of the mp4 file, the text is above but its simply a big white box, rather than it just being the text, but thanks for letting me know why it is that my text would never show up haha, It was getting on my last nerves, I may just simply go into my psd file and adding text over all the layers that made the video then using just the mp4 as the first slide without having to go in and adding text with indesing. Hopefully there is a way to work around it, I hate rendering videos with photohsop, takes foreve.

  • Created a pdf file showing a graph generated with CL_GUI_CHART_ENGINE

    Hi Experts!
    Please, anyone has already created a pdf file showing a graph generated with CL_GUI_CHART_ENGINE??
    Could anyone help me with this requirement?
    Thanks in advance,
    Best regards

    Hi,
    I searched and found another solution, because with the code from the link above I got everytime a short dump, maybe I did something wrong.
    The solution works with Adobe Form
    1. I used the class cl_igs_chart_engine to create a chart with my data and customizing to get the binary data of the image.
    2. Convert the binary tab to xstring.
    3. You can use this xstring on the Adobe Form to display the image.
    Maybe the following tips are useful.
    *How to get the data of chart you can see in the class
    CL_TIME_CHART_SIMPLE (use cl_gui_chart_engine for the chart but  class cl_igs_chart_engine for saving the image)
    *How to bind the image to the importing parameter (xstring)
    /people/thomas.jung3/blog/2005/07/13/lessons-learned-from-adobe-forms-development
    Regards

  • Generated pdf file from oracle reports show bad characters

    Hello all,
    Iam fighting with a problem with generated pdf file from oracle reports which show some bad characters. I was searching for some information but it didnt help...
    I have Oracle Database 11g R2 (or 10g R2) on Oracle Linux or Windows, Oracle forms and reports 6i (i know that is very old and not supported with 11gr2 but we are in this scenario).
    NLS parameters are set like this
    server:
    NLS_CHARACTERSET EE8MSWIN1250
    NLS_TERRITORY AMERICA
    NLS_LANGUAGE AMERICAN
    client:
    NLS_CHARACTERSET EE8MSWIN1250
    NLS_TERRITORY SLOVAK
    NLS_LANGUAGE SLOVAKIA
    When I run Oracle Reports it show perfect in display and when I try to print them, they are all good with good characters, but when I try to generate pdf file, some characters like č,š,ľ are not displaying corectly... This happen only when try to generate to pdf...
    I try to work with uifont.ali on client side but without any result. Fonts for reports were installed on client and server side... Can someone help me with this problem? Thank you very much for every advice.
    Martin

    Hi Sergiusz,
    Thank you for your reply. I look at what you wrote and try to make some test...
    1) For first I download FontForge, which can generate type1 font from true type. So I open FontForge and open my Arial.ttf font and use "Generate Fonts" to save my Arial.ttf font to pfb and pfm (whoch are need to set in uifont.ali). I have to change encoding, because my font has 2byte encoding so I reecondode the font from ISO10646-1 to ISO8859-2 and generate to pfb.
    2) Then I navigate REPORTS_PATH from regedit to my *.pfm and *.pfb files.
    3) I add these lines to end of my uifont.ali
    [ PDF:Embed ]
    Arial = "Arial.pfm Arial.pfb"
    ArialNarrow = "ArialNarrow.pfm ArialNarrow.pfb"
    4) Then I generate my report but nothing change... I check "Font used" in my pdf file, but there were not my fonts embedded I guess..
    I also try PDF:Subset, but it doesnt change anything... I try PDF aliasing to see if my uifont is working - this work very well, but I dont need to change font...
    Any other advice? Thank you so much to everyone!
    Martin

  • How to generate pdf from servlet?

    i have problem when running sample FopServlet in fop-0.20.3xxx version, the error seems like NoClassDefFoundError: org/apache/fop/apps/XSLTInputHandler as follow A):
    the structure i place the FopServlet looks like ; where did i do it wrong?
    for i am not familiar with sax and fop, so hope could get a sample which can run or someone else would like to tell me the methods that must be done to make servelt be able to generate pdf!
    thanks in advice,
    <code>
    weapps
    |
    + ---fop
    |
    + WEB-INF
    |
    +---classes
    |
    + -------- FopServlet
    </code>
    A)
    javax.servlet.ServletException: Error instantiating servlet class FopServlet
         at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:829)
         at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:615)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
         at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
         at java.lang.Thread.run(Thread.java:484)
    root cause
    java.lang.NoClassDefFoundError: org/apache/fop/apps/XSLTInputHandler
         at java.lang.Class.newInstance0(Native Method)
         at java.lang.Class.newInstance(Class.java:237)
         at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:820)
         at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:615)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
         at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
         at java.lang.Thread.run(Thread.java:484)

    now i am able to see the result generated via FopServlet, but another question now aroused, that's -how am i able to generate *.fo on the fly by which the servlet make use of it to create pdf file.
    thanks in advice,

  • I just loaded Lion oxs 10.71 and now my Logic 9 software wont show up it says its not compatible also i cant find my macintosh harddrive icon that is usually shown on dektop and device browser column can anyone help me with this problem

    I just loaded Lion oxs 10.71 on my I-mac computer, and now my Logic 9 software wont show up it says its not compatible also i cant find my macintosh harddrive icon that is usually shown on dektop and device browser column can anyone help me with this problem.

    Mike,
    I had a similar issue with Photoshop when I upgraded to both Snow Leopard and Lion.  it turned out to be Rosetta is no longer present in the newer OS.  Once I upgraded to Lion, Appleworks stopped working after all these years.

  • When i upload my site, it wont show the changes i have made in the browser. How do i upload properly?

    when i upload my site, it wont show the changes i have made in the browser. How do i upload properly?

    Hi Ashley,
    Is it possible that you can share your site url so that I can check that? Also, what are the changes that you are making? Are you hosting the site on business catalyst?
    - Abhishek Maurya

  • Generating PDF from Flex BarChart

    Hello,
    I am new to Flex. Have been playing with creating Advanced
    Data Grid and Bar Charts for our application prototype and would
    like to explore how to create a PDF file of the BarChart or other
    charting components.
    The requirement is simple. We show the BarChart and a button
    to view it as a PDF. When the user presses the button, the PDF
    viewing dialog should come up and the user can opt to save the PDF
    or view it (the standard way a browser deals with the PDF).
    Have read blogs, this forum and LiveCycle docs but don't
    understand clearly how Flex communicates with
    LiveCycle ES (or PDF Generator) to display the PDF. Any ideas
    or tutorials that does this would be appreciated.
    Thanks,
    Kannan

    In order to generate a PDF document, you have to call a
    method on a Java remote object that uses the XFAHelper and pass it
    some arguments.
    I modified the PDFService example in the documentation so I
    can:
    1- specify any document as opposed to hardcoding the PDF
    template name
    2- write the PDF to a file as opposed to writing it in the
    user's session
    Here is the source:
    package com.mycompany.flex.remoteObjects;
    import java.io.File;
    import java.io.IOException;
    import org.w3c.dom.Document;
    import flex.acrobat.pdf.XFAHelper;
    import flex.messaging.FlexContext;
    import flex.messaging.util.UUIDUtils;
    public class PDFService
    public PDFService()
    public Object generatePDF(Document dataset, String
    PDFdocument) throws IOException
    // Open shell PDF
    String source =
    FlexContext.getServletContext().getRealPath("/pdfgen/" +
    PDFdocument);
    int index = source.indexOf("./");
    if(index != -1 )
    // Remove the ./ added by UNIX
    source = source.substring(0, index) + source.substring(index
    + 2, source.length());
    XFAHelper helper = new XFAHelper();
    helper.open(source);
    // Import XFA dataset
    helper.importDataset(dataset);
    // Create a unique ID
    String uuid = UUIDUtils.createUUID(false);
    source =
    FlexContext.getServletContext().getRealPath("/dynamic-pdf/" + uuid
    + "_" + PDFdocument);
    index = source.indexOf("./");
    if(index != -1 )
    // Remove the ./ added by UNIX
    source = source.substring(0, index) + source.substring(index
    + 2, source.length());
    // Create the file object
    File file = new File(source);
    // Save the file
    helper.save(file);
    // Close any resources
    helper.close();
    return (uuid + "_" + PDFdocument);
    pdfgen is the folder where my PDF template resides.
    dynamic-pdf is the folder where the generated PDF are saved.
    These two folders are located under flex.war at the first
    level.
    In Flex, I wrote a Cairngorm command that calls this remote
    object and displays the generated PDF:
    package com.mycompany.core.commands
    import com.adobe.cairngorm.commands.ICommand;
    import com.adobe.cairngorm.control.CairngormEvent;
    import com.adobe.cairngorm.business.Responder;
    import
    com.mycompany.core.business.GenerateAndOpenPDFDelegate;
    import
    com.mycompany.core.control.event.GenerateAndOpenPDFEvent;
    import com.mycompany.core.model.ModelLocator;
    import flash.net.navigateToURL;
    import flash.net.URLRequest;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.events.FaultEvent;
    import mx.collections.*;
    import mx.core.Application;
    import mx.controls.Alert;
    public class GenerateAndOpenPDFCommand implements ICommand,
    Responder
    [Bindable]
    private var model:ModelLocator = ModelLocator.getInstance();
    public function GenerateAndOpenPDFCommand():void
    public function execute(event:CairngormEvent):void
    trace("Executing GenerateAndOpenPDFCommand...");
    var delegate : GenerateAndOpenPDFDelegate = new
    GenerateAndOpenPDFDelegate( this );
    var generateAndOpenPDFEvent : GenerateAndOpenPDFEvent =
    event as GenerateAndOpenPDFEvent;
    delegate.generateAndOpenPDF( generateAndOpenPDFEvent.pdfVO
    public function onResult( event : * = null ) : void
    var item:Object;
    var result:String = (event as ResultEvent).result as String;
    trace("GenerateAndOpenPDFCommand::onResult\n\n" + result);
    if (result)
    // Open the generated PDF in a new window
    navigateToURL(new URLRequest(ModelLocator.FLEX_URL +
    "dynamic-pdf/" + result), "_blank");
    // Hide the progress bar overlay
    Application.application.requestProgressBar.visible = false;
    Application.application.requestProgressBar.progressBar.source =
    null;
    Application.application.requestProgressBar.progressBar.label
    = this.model.languageDictionary["000012"];
    public function onFault( event : * = null ) : void
    // Hide the progress bar overlay
    Application.application.requestProgressBar.visible = false;
    Application.application.requestProgressBar.progressBar.source =
    null;
    // Debug
    Alert.show("GenerateAndOpenPDFCommand:\n\n" + (event as
    FaultEvent).message);
    FLEX_URL is created in this way some place else in the
    application:
    // Get the server URL from the Application's
    var server:String = Application.application.url;
    var index:uint = server.indexOf("Shell"); // Shell is the
    name of my app folder
    server = server.substring(0, index);
    // This is the flex.war/ URL
    ModelLocator.FLEX_URL = server;
    Of course, it would be better to save the PDF in the user's
    session as Adobe suggests, but I couldn't figure out how they use
    the PDFResourceServlet. First of all, I had to get its code.
    I had to decompile the java class files in the samples to get
    the source of the PDFResourceServlet as it is not in the
    documentation. Here it is:
    package com.mycompany.flex.remoteObjects;
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    public class PDFResourceServlet extends HttpServlet
    public PDFResourceServlet()
    protected void doGet(HttpServletRequest req,
    HttpServletResponse res)
    throws ServletException, IOException
    doPost(req, res);
    protected void doPost(HttpServletRequest req,
    HttpServletResponse res)
    throws ServletException, IOException
    String id = req.getParameter("id");
    if(id != null)
    HttpSession session = req.getSession(true);
    try
    byte bytes[] = (byte[])(byte[])session.getAttribute(id);
    if(bytes != null)
    res.setContentType("application/pdf");
    res.setContentLength(bytes.length);
    res.getOutputStream().write(bytes);
    } else
    res.setStatus(404);
    catch(Throwable t)
    System.err.println(t.getMessage());
    private static final long serialVersionUID =
    0x7180e4383e53d335L;

  • "Error while generating pdf" error come when clicking on "Print Version "

    Hello ,
    When we execute Query in the Portal there is a 'Print version' button.
    When you select it, it opens up print dialog and click OK
    It is supposed to send 'pdf' stream to  Web browser client on end user but it is not able to generate the pdf .
    getting ' Error while generating pdf '
    I am working on BI 7.0 .
    The same is running fine in the Q Environment .But in Production we are getting this error .
    Thanks ,
    Rahul

    Hi,
    I think this is an ADS error. This is a reason why pdf's are not working. We had the same issue.
    You can check your installation:
    Usage of SAP NetWeaver BI Diagnostics & Support Desk Tool
    SAP Note Number: [937697|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes/sdn_oss_bw_bex/~form/handler%7b5f4150503d3030323030363832353030303030303031393732265f4556454e543d444953504c4159265f4e4e554d3d393337363937%7d]
    Exceptions: Prerequisites for messages in the area BI Java
    SAP Note Number: [1224043 |https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes/sdn_oss_bw_bex/~form/handler%7b5f4150503d3030323030363832353030303030303031393732265f4556454e543d444953504c4159265f4e4e554d3d31323234303433%7d]
    Solution in our case was to update the SAPADS package to 7.00 17.1
    Regards
    Andreas

  • How to generate PDF with bookmarks?

    Hi,
    The business request is to have pdf report with bookmarks. There is no predefined bookmark object in Livecycle Designer/SFP so my idea is to add some scripting to the form to generate bookmarks dynamically. I defined a standard pdf form with several lines of JavaScript embedded. The script is running in the form preview in Livecycle  Later I was testing the form by calling its function module and looking at the generated PDF file. Unfortunately it seems there is no script embedded in the final output PDF generated by ADS.
    Is Javascript supported in pdf forms? Do I need to perform any additional operations to enable the Javascipt? Do I need to pass additional parameters to ADS? I tested the following settings:
           fp_docparams-fillable = 'X'.
           fp_docparams-DYNAMIC = 'X'.
           fp_outputparams-getpdf = 'X'.
           fp_outputparams-PDFTAGGED = 'X'.
           fp_outputparams-PDFCHANGESRESTRICTED = ' '.
    I appreciate any suggestion.

    Hi Lata,
    May be there is some error in the JavaScript code written.
    Sometimes if there is an error in JavaScript then from where the error occurs from there the JavaScript wont work in the Adobe Form.
    To check whether JavaScript contains errors or not. You just simply open your Adobe Acrobat Reader goto Edit in that goto Preferences and in that Select "JavaScript" in that you find the JavaScript Debugger there you enable "Show Console on errors and messages".
    This may help you in some way or the other.
    Regards
    Pradeep Goli

  • Weblogic 12c Servlet Response - Special characters show up as question mark

    My web app is running on Weblogic 12c (12.1.1) using WebWork + Hibernate. The program streams data (bytes making up a pdf) from a CLOB in an Oracle Database to the AsciiStream of the servlet output response. No exceptions are thrown, but the generated pdf contains blank pages. Comparing the bytes of the generated pdf, special characters are showing up as question marks.
    Some of the bytes read in from the database contain 8 bits (correct data), but the bytes that the servlet return contain only 7 (all bytes with 8 bits become "1111111"). The number of bytes returned from the servlet is correct.
    Code:
    //Response is HttpServletResponse
    response.setContentType("application/pdf");
    response.setHeader("Content-Disposition", "inline; filename=\"test.pdf\"");
    out = response.getOutputStream();
    byte[] buf = new byte[16 * 1024];
    InputStream in = clob.getAsciiStream();
    int size = -1;
    while ((size = in.read(buf)) != -1){
    // buf contains the correct data
    out.write(buf, 0, size);
    // other exception handling code, etc
    out.flush();
    out.close();
    "Correct" pdf byte example:
    10011100
    10011101
    1010111
    1001011
    1101111
    11011011
    Incorrect pdf byte example:
    111111
    111111
    1010111
    1001011
    1101111
    111111
    I have verified that the data read from the CLOB in the database IS correct. My guess is that the Weblogic server has some strange servlet settings that causes the bytes to be written to the servlet output stream incorrectly, or a character encoding issue. Any ideas?
    Edited by: 944705 on Jul 26, 2012 10:17 AM

    Solution found, I'll post the work around to those who might encounter the same problem.
    Somewhere in the layers of technology (webwork or weblogic I'd guess), the servlet response is encoded into UTF-8 regardless. The encoding in the database was ISO-8859-1. Sending ISO encoded bytes by UTF-8 caused the conflicting character codes (anything above 127) to show up as undefined.
    The fix is to decode the input byte array into ISO-8859 string, then encode that string into UTF-8, which can be send by Weblogic.
    isoConvert = new String(buf, "ISO-8859-1");
    out.write(isoConvert.getBytes("UTF-8"), 0, isoConvert.getBytes("UTF-8").length);

Maybe you are looking for