Help whit open file!!!!!Urgent

hi
i have 1 great problen whit my servlet.
I use Fop class for create pdf file from xml and class work very well, but i need translate this class in a servlet class and when open file on the fly in browser size of this is equals a 0kb why?
this is may code:
//Java
import java.io.File;
import java.io.OutputStream;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.*;
//JAXP
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Source;
import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.sax.SAXResult;
//FOP
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;
//passaggio di parametri(da xml a pdf)
public class generatePDF extends javax.servlet.http.HttpServlet
public void doGet(HttpServletRequest req,HttpServletResponse response) throws ServletException,IOException
     try {
     File baseDir = new File("xml/");
     baseDir.mkdirs();
File xmlfile = new File(baseDir, "mail.xml");//file in entrata(stream xml)     
File xsltfile = new File(baseDir, "carrello.xsl");//file di decodifica xsl
File pdffile = new File("Testpdf.pdf");//file temporaneo d'appoggio pdf
FopFactory fopFactory = FopFactory.newInstance();
     FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
OutputStream outi = new java.io.FileOutputStream(pdffile);
outi = new java.io.BufferedOutputStream(outi);
try {
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, outi);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource(xsltfile));
transformer.setParameter("versionParam", "2.0");
Source src = new StreamSource(xmlfile);
          Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, res);
} finally {
          response.setContentType("application/pdf");
          response.setHeader("Content-disposition","attachment; filename="+pdffile.getName());
          response.flushBuffer();
          outi.close();
          pdffile.delete();
} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
please help my for adjust my code, where is the errors?
i use tomcat 5.5

Likely because you are not setting the content length. The rest of the code doesn't look fine however.
At the bottom of this article you can find a valuable downloadFile() snippet which might give new insights: http://balusc.xs4all.nl/srv/dev-jep-pdf.html
By the way, please use normal topic titles. You don't need to put pressure. We don't care less if it is urgent or not. That is totally your own problem.

Similar Messages

  • IPod Shuffle Help - Cant open files on ipod (blank screen)

    I'm sure it's already been covered here, but I couldn't find anything that helped.
    I have a iPod shuffle, and iTunes recognises it but wants to re-format it (not my biggest problem), and Windows only partially recognises it.
    In My Computer it is listed as an iPod (E:), but when i open it, which it does, it displays a blank screen. It doesn't recognise any files in it AT ALL. But recognises how much free space i still have on my ipod. I can open my ipod files (Songs) on friends and school computers, just not mine.
    It just seems that i'm missing a file of some sort, which is able to read the files on my ipod shuffle, but i just don't no what it could be.
    I have tried every available solution, reinstalling iTunes/iPod, with no luck. I also just added service pack 2 for my windows xp pro and thought that would have solved my problem.
    Any suggestions?
      Windows XP Pro  
      Windows XP Pro  
    cant open up files on ipod (blank screen)

    Have you tried syncing it again? There might be some error during the last sync.. If nothing's wrong, on the left panel, there's your iPod, click on the arrow beside the icon and there's everything..

  • Brio query help - Cant open file

    Hi there
    I need so BIG help
    I have been busy for hours on a query in Hyperion and I save the query then it returned a "Error please restart your app"
    I did so and now all I get is
    "system stack trace unavailable" error and I can't open the file.
    I have tried of different versions of BRIO on different PC and it returns this errors "There was a problem reading file"
    Is there a repair utilities to repair my file ?
    Or can you advise any other ideas ?
    Big thanks
    Mark

    Mark,
    Sorry, SR = Service Request.
    Do you remember what section you were working on when the file broke?
    It, has been a while since I have worked in the 8.x tools. Do you have access to Dashboard Builder tools? Merge? Optimizer?
    Things I have tried in the past are:
    - Merge the broken file into a known good file.
    - Use Optimizer to delete out the section you had problems with and save as a new file and see if you can open it
    Wayne Van Sluys
    TopDown Consulting

  • Help with opening files

    I have two different psd files I cannot open.
    I last worked on these files May 30th.  For each of them I completed a detailed mask, added a path and saved the files without changing the name.
    Today I went to work on my project and could not open either file.
    When opening the 1st file I got this error message:
    Could not complete your request becaus the file is not compatible with this version of Photoship.
    When opening the 2nd file I got this error message:
    Could not complete your request because it is a not a valid Photoshop document.
    Thanks in advance for your assistance.
    Windows Vista
    HP Pavillion dv71133cl
    PhotoshopCS4

    :::sigh:::     
    I hate to think that this flash drive defective as it contains many psd files.
    Earlier in the week I backed up my flash drive to my desktop computer that doesn't have Photoshop.  I just transferred the 2 files to a different flash drive and they do not open either.
    I need to get a larger hard drive for my laptop!!!  And, in the future I will save to the hard drive and then move to my flash if needed.
    Is there any way to recover my files?
    thanks

  • Need help with opening file

    Hi All,
    I have several files like the one below that Apple transferred from my old PC to my macbook when I bought it. I would like to open them up and see what is in them but do not know how. They do not open with iPhoto. If I try to I get a window saying unreadable script.
    Here is the window when i try to open with iphoto:
    I am currently with 10.6. When the files were imported from the old PC I was at 10.5.  I'd like to open them to see if I want to keep them or not.
    Thanks
    Ron

    I got your last reply about the incompatability via e-mail notification. However I could not open a new window to respond directly.
    Anyway, I have been able to open most of the old PC stuff but I have not paid attention as to what file types work or not. Sounds like your correct though with the incompatability.
    Thanks
    ROn

  • MORE HELP ON TEXT FILES - URGENT

    I'm Writing a Business Professionals Of America Database for the High School I attend and I need to know about some input and output to text files
    Suppose I have a String called 'line1'
    I also have a textfile called 'C:/......../info.txt'
    In that text file I have the line '34865-M-J-101'
    Can someone show me how to take that line out of the text file and place it into 'line1'???
    The second thing I need to know is.............
    I have a TextField in my java program, once the user enters something into the textfield and clicks a button I made, I need to take that information and output it to a text file. I know how to take the information OUT of the textfield and into a variable, I just need the code on how to output the variable's information to a textfile.

    I'm Writing a Business Professionals Of America
    Database for the High School I attend and I need to
    know about some input and output to text filesHow much information do you have. If there is a lot of information I would recommend using an actual database instead of a text file.
    Suppose I have a String called 'line1'
    I also have a textfile called 'C:/......../info.txt'
    In that text file I have the line '34865-M-J-101'
    Can someone show me how to take that line out of the
    text file and place it into 'line1'???That looks like some kind of ID. What you could do (also I'm assuming you don't have a tremendous amount of data, otherwise use an actual database) is use the java.util.Properties class and setup your data as lines with "34865-M-J-101=some entry for that". Then you could use code like:
    Properties props=new Properties();
    props.load(new FileInputStream("C:/....../info.txt"));
    String line=props.getProperty("34865-M-J-101");The line would then have "some entry for that".
    The second thing I need to know is.............
    I have a TextField in my java program, once the user
    enters something into the textfield and clicks a
    button I made, I need to take that information and
    output it to a text file. I know how to take the
    information OUT of the textfield and into a variable,
    I just need the code on how to output the variable's
    information to a textfile.Assuming you took the approach above something like:
    props.store(new FileOutputStream("C:/....../info.txt", null));The best way to do this really depends on how much information there is and what you need to do with it. For example, if you do not have some unique key for each entry, you probably don't want to use properties.

  • Opening file in a new tab/window

    Hi,
    I have a form (HTML added through a widget) and a number of images on one page. I want each image to be a link to a file, where the images will be seen full quality. however, doing this takes visitors away from the page instead of opening a new tab/window - then clicking back means that the form data is lost - i.e. tickboxes are no longer ticked, etc.
    I cannot use the photo viewing page included in iWeb, as the pictures will then overlap with my form because the enlarged images are loaded on the same page.
    I hope this makes sense, and if anyone could help with opening files in new tab/window it would be great, or a way of opening a photo viewing platform in a separate tab/window directly from a click of one of the photos. I have seen other sites - http://www.aroundthebusch.com/Folio/London%20to%20Istanbul.html
    (this is not mine) where the photo viewing "platform" is IDEAL. I would love something just like this if someone could advise.
    i do not want the photos to link to an external page (which can be opened in a new window) as it would mean me creating separate pages for each picture, and linking them all... no way!
    Also, it would obviously be preferable to be quick to set up, but also to change. I would need to have multiple pages of many photos, each with the viewing facilities so it could not take a long time to set up. I may also need to add/delete some photos, so if all the linking work was done automatically it would be fantastic.
    Any help much appreciated,
    Thanks in advance, James

    If you open it in javascript and specify a height/width or location it should open in a new window.
    window.open("http://www.adobe.com", "_blank", "toolbar=yes, scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400");

  • I am trying to open CR2 files from a Cannon EOS 1DX camera in Photoshop CS6 and I have already updated the Camera Raw Plug in but Photoshop is still giving me the cannot open files dialog box? Help?

    I am trying to open CR2 files from a Cannon EOS 1DX camera in Photoshop CS6 and I have already updated the Camera Raw Plug in but Photoshop is still giving me the cannot open files dialog box? Help?

    Canon 1DX support was added to ACR in version 6.7, 7.1.  An updated CS6 should be at level ACR 8.6.  If your ACR is not at level 8.6 try using CS6 menu Help>Updates.  If that does not install ACR 8.6 try downloading the ACR and DNG 8.6 converter and see if ACR 8.6 will install into your CS6.
    Adobe - Adobe Camera Raw and DNG Converter : For Windows
    Adobe - Adobe Camera Raw and DNG Converter : For Macintosh

  • Need help to open and look for file by name

    Hi,
            Im needing help to open a folder and look for a file (.txt) on this directory by his name ... The user ll type the partial name of file , and i need look for this file on the folder , and delete it ....
    How can i look for the file by his name ?
    Thx =)

    Hi ,
        Sry ,, let me explain again ... I ll set the name of the files in the follow order ... Name_Serial_date_chanel.sxc ..
    The user ll type the serial that he wants delete ...
    I already figured out what i need guys .. thx for the help ^^
    I used List Directory on advanced IO , to list all .. the Name is the same for all ... then i used Name_ concateneted with Serial(typed)* .. this command serial* ll list all serials equal the typed , in my case , ll exist only one , cuz its a count this serial .Then i pass the path to the delete , and its done !
    Thx ^^

  • HELP. ............Hi folks hope some one can help me please.Having a problem in Bridge I open my images in ACR,  as I open files in a folder and lets say they are labeled in yellow  they are all going back to  the camera raw default , in other words no ma

    HELP. ............Hi folks hope some one can help me please.Having a problem in Bridge I open my images in ACR,  as I open files in a folder and lets say they are labeled in yellow  they are all going back to  the camera raw default , in other words no matter what work I have done, inc cropping they  all go back to ,as they came out of camera. What on earth is happening? I am on PS CS6. I might point out everything was working normally up to  yesterday, when this first started.
    I recently changed computer to 64bit from 32bit, not sure if this causing  the problem or not. Any help would be appreciated.

    Robert,
    Would you be so kind to rephrase your question with concise, precise information and without any "let's say that" hypotheticals?  Sorry, I can't quite follow you.
    Also please give exact versions of Photoshop CS6 (13.what.what), of Bridge and of your OS.
    Thanks.
    BOILERPLATE TEXT:
    If you give complete and detailed information about your setup and the issue at hand, such as your platform (Mac or Win), exact versions of your OS, of Photoshop and of Bridge, machine specs, what troubleshooting steps you have taken so far, what error message(s) you receive, if having issues opening raw files also the exact camera make and model that generated them, etc., someone may be able to help you.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • "Cannot open Help. The file cannot be found." Error on Treo Pro

    I can see a support item listed on my phone when I try to search the Help files, but when I click on that item, it gives me an error message, "Cannot oepn Help.  The file cannot be found."
    I am trying to block telemarketer calls, and it looks like there is a way to do it.  Two help references come up - "Setting Options for rejecting calls" and "Blocking Calls."  I just can't access them.
    Thanks in advance!
    Shan
    Post relates to: Treo Pro T850 (Sprint)

    From the Owners Guide http://www.palm.com/us/support/handbooks/treopro/t​reoproT850E_UG.pdf But I dont think its what your looking for.
    Setting options for rejecting a call  By default, when you reject an incoming
    call, the caller is sent to voicemail. You can
    change this setting so that, in addition to
    sending the caller to voicemail, a text
    message opens. This message contains
    default text and is addressed to the caller
    so that you can send the message right
    away. You can also change the default text
    of the message.
    1 Press Start and select Settings.2 On the Personal tab, select Phone .3 Select the Advanced tab.4 To turn on the text message feature, check the Reject call with text
    message box.
    5 (Optional) To change the content of the message, select the text in the box and
    enter the text you want.6 Press OK . 

  • The latest issue of Pages for iPad: 1. Very slow. 2. Late in reacting to typing. 3. When I go to a specific file, informs me that some images were deleted and therefore file has been changed. Then when OPEN option used, opens file slowly. Please, help!

    What I have to do to correct the following problems with Pages app. For iPad:
    Hesitates to display results of typing, some times for 5-6 characters;
    Very slow in opening files;
    Before opening of a specific file displays message: DOCUMENT DETAILS. SOME CHANGES WERE MADE TO YOUR DOCUMENT. SOME IMAGES ARE MISSING BECAUSE THEY WERE DELETED FROM YOUR DOCUMENT. We'll, nothing is missing. But it takes forever to open this file. The previous issue of Pages worked very good. But they would not let me to go back to it. Please, help!

    Tmobile did the exact same thing to me. So that is customer service at work in general. Nice try though lol.
    To the OP
    I see you said You paid for shipping, did you Insure it? Claim insurance on it. If you did not, It may not be Verizon or your fault in the sense of the phone not making it to the warehouse. There are people out in the postal world that will steal phones that are not insured. It could have been a Verizon employee, i suppose.
    But, if this was to be a bought in court, if you shipped it with out insurance, sadly your at fault.
    Do you still have the Serial number of your old phone? If so, you should be able to track where your phone is (if it is reported as a defect/damaged) If so, you may be able to use that as proof. If it does not show up as a defect or what ever they determine use as a loss, then you know it did not make it to the warehouse to be checked in. I would suspect Apple or Verizon could tell you what the Serial number came up as.

  • Can anyone help me open these InDesign files?

    I've been trying all day to open files for a project I was working on in March with InDesign.  I could open them in March but now my computer is either crashing from trying to load the folder that contains the files, or it gives me one of two error messages.  The first saying I don't have permission to open the file, the second saying the file is already open with another user.
    I have tried opening from my computer and from an external drive, neither work.  I have tried restarting.  I've tried opening as a copy, original and normal.  I've tried opening InDesign as an administrator.  I have tried phoning Adobe and have been on hold for 25 minutes so far.  I have tried the online help but nobody available there.  I don't know what else to try.
    I can create a new InDesign files and I'm not having any trouble with any other Adobe products.  My subscription is until 29th August.  Any ideas appreciated.
    Thanks,
    Angs

    If you open it in a plain text editor, what do the first few lines look like? If there's no lock file, the next most likely cause for this error is that the files aren't really .indd files.

  • Hi. Having trouble viewing a downloaded file from a site. iPad is telling has not got a app to open file ,but have downloaded so many now and none of them are any help. Tried this on my android phone still nothing. Please can anyone help as slowly ma

    HHi having trouble viewing a downloaded file from a site my iPad is telling me I don have a app to open file . And have downloaded loads of apps and still no joy . Have tried this on my android phone to and still nothing. Please can anyone help as slowly going crazy. Thanks tim

    What type of file?  From what site?  What Apps have you downloaded for it?
    Perhaps if you provide details of what you are doing we can provide more precise help.

  • Need help. I am running a 27 in imac with 16 gigs of ram. Photoshop runs really fast, except when opening files. It takes 5-10 minutes to open even a small file of 1 meg. I cleaned and validated all the fonts and removed all questionable fonts. Reset pref

    Need help. I am running a 27 in imac with 16 gigs of ram. Photoshop runs really fast, except when opening files. It takes 5-10 minutes to open even a small file of 1 meg. I cleaned and validated all the fonts and removed all questionable fonts. Reset preferences and still have problem. Slow to open and in force quit "Photoshop not responding" At this point should I uninstall and start over.

    What are the performance Preferences?

Maybe you are looking for