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

  • Home
  • SEARCH
  • 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 765259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:51:38+00:00 2026-05-14T16:51:38+00:00

Is it possible to a jquery $.get() to call a servlet and use it

  • 0

Is it possible to a jquery $.get() to call a servlet and use it to both download a file or update the page without reloading the page? (Or more basically, can I download a file without reloading the page?)

For example, I am using a servlet that either returns a file to download of mimetype “application/octet-stream”, or returns text to be update in the page of type “text/html”.

I can write a form with a submit, but then it reloads the page, so I’ve been trying to use $.get()… but the download doesn’t work.

<script type="text/javascript">
 jQuery(document).ready(function(){ 
   $("#handleFileOptions button").button();
  });

  function handleFilesSubmit(requestType)
  {
     $.get('FileServlet', {filename: $('#radioFileList input:radio:checked').button("widget").text(), requestType: requestType}, function(data){ ...?... });
   }
</script>

In the html:

<div id = "handleFiles">
 <div id ="radioFileList">
   <div id="radioFileList">
     <input value="file0.txt" type="radio" id="fileitem0><label for="fileitem0">file0.txt</label>
     <input value="file1.txt" type="radio" id="fileitem1><label for="fileitem0">file1.txt</label>
   </div>
 </div>
 <div id="handleFileOptions">
   <button id="handleFileOption0" onclick="handleFilesSubmit('Download')">Download</button>
   <button id="handleFileOption1" onclick="handleFilesSubmit('Delete')">Delete</button>
 </div>
</div>

Solution As per the suggestion below, I changed the submit function to load the servlet directly as:

function handleFilesSubmit(requestType)
{
  if(requestType == "Download"){
     window.location.replace("FileServlet?filename="+$('#radioFileList input:radio:checked').button("widget").text()+"&requestType="+requestType);
  }
  else {     
     $.get('FileServlet', {filename: $('#radioFileList input:radio:checked').button("widget").text(), requestType: requestType}, function(data){ ...?... });
  }
}
  • 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-14T16:51:38+00:00Added an answer on May 14, 2026 at 4:51 pm

    Actually, have you tried just having it load the file to download? Most browsers will detect it is a file, and not navigate away from the page. They will just show the download dialog box.

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

Sidebar

Related Questions

Is it possible to use a jQuery ajax call to perform Forms Authentication with
Is it possible to use SimpleModal (jquery plugin) with ASP.NET MVC? Since it has
When I'm trying to call an ascx with Jquery post I get: This type
Is it possible using jQuery to select all <a> links which href ends with
Is it possible that using jQuery, I cancel/abort an Ajax request that I have
Is it possible to add a jQuery function so that a click in a
Is it possible to catch an error when using JSONP with jQuery? I've tried
Is it possible to rename all the tabs in a jQuery UI tab control?
Using the jQuery UI Tabs component, is it possible to select new tabs on
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should

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.