Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7406411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:33:15+00:00 2026-05-29T05:33:15+00:00

I am developing a web app that in some moment the user requests something

  • 0

I am developing a web app that in some moment the user requests something for the server (servlet) and the server should return a csv file to the user. I need at this point a dialog box appears to the user, giving you the option to specify the directory where you want to save the csv file.

In Servlet I have:

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        response.setContentType("application/csv");
        response.setHeader("content-disposition","filename=test.csv"); // set the file name to whatever required..
        PrintWriter out = response.getWriter();
        out.println("a,b,c,d,e,f");
        out.println("1,2,3,4,5,6");
        out.flush();
        out.close();
}

In javascript I have:

            $.get('URL_SERVLET' , function(data) {
            alert("ret: " + data);
        });

How is the next step?

EDIT:

I got a good result using the simple following command:

<a href='http://localhost:8080/MY_SERVLET'> link here </ a>

Clicking on the link, the file test.csv is automatically downloaded

To Answer my need, I need that “href” content was dynamic and was fired by the click of a button.

example:

User select radio component with name “radio 1” and clicked the button “Export csv”, this time the url would be built dynamically, example: “http://localhost:8080/MY_SERVLET/csv1&#8221; and the file would be downloaded automatically (equal what happens on the link above that contains the text “link here”)

Is possible?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:33:15+00:00Added an answer on May 29, 2026 at 5:33 am

    You can’t trigger the save-as dialog with ajax. You should simply navigate the browser to the download url. It will detect the proper headers and will show the save-as dialog.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing web app that user can save his/her work to server. The data
I am developing an Android App that gets some data from a web server,
I am developing a small web app that internally authenticates users. Once the user
I'm developing a web app that needs some sort of filesystem access. Ideally I'd
I'm developing a web app that needs to do some backend processing while still
We are developing the Web App that will have user subscription to a specific
I am developing a web app that accesses some external JSON data. I'm currently
I'm developing a web app that emulates a generic file browser for the desktop,
I'm developing an iPhone web app following some of the suggestions that can be
I am developing a web app (using rails) that I will be launching within

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.