Problem Writing to a CSV from a JSP behind a Security Constraint

Discussion in 'Java' started by Justin, Aug 8, 2003.

  1. Justin

    Justin Guest

    I am trying to write to a CSV for the user to download through my JSP.
    The following is the entire JSP test page (MyJsp.jsp) I created:

    out.println( "a,b,c" );
    out.println( "10,34,55" );

    When I run this file in IE6 from my project that has a security
    constraint set in the web.xml, the download window popups up and
    prompts the client to download. Saying the file name is MyJsp.jsp and
    the file type is blank. When I try and save or open the file I get the
    following error:

    "Internet Explorer cannot download MyJsp.jsp from localhost.
    Internet Explorer was not able to open this Internet site. The
    requested site is either unavailable or cannot be found. Please try
    again later."

    If I remove the security constraint it works fine, but I would need
    this process to run only for authenticated users. I have tried this on
    both Tomcat 4.1.24 and 5.0.3 and had the same results.

    Any help is greatly appreciated.

    Justin Erickson
    Justin, Aug 8, 2003
    1. Advertisements

  2. Justin

    Scott Yanoff Guest

    Here are a couple of things to try:
    1) Since it is a CSV file, try setting the content type to "text/csv".
    However, I am not sure if you then have to set the browser to use Excel
    for this type of document.

    2) Some versions of IE seemed to appreciate it if the URL ended with the
    extension of the file you are attempting to download/save. You can do
    this with a dummy parameter at the end of the URL. For example:
    So, it might help by making references to your JSP end with that dummy
    query string.

    Good luck,
    Scott Yanoff, Aug 11, 2003
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.