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 768217
In Process

The Archive Base Latest Questions

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

I have a webpage that makes an ajax call to get some data. That

  • 0

I have a webpage that makes an ajax call to get some data. That data takes a long time to calculate, so what I did was the first ajax server call returns “loading…” and then the thread goes on to calculate the data and store it in a cache.
meanwhile the client javascript checks back every few seconds with another ajax call to see if the cache has been loaded yet.

Here’s my problem, and it might not be a problem. After the initial ajax to the server call, I do a

...getServletContext().getRequestDispatcher(jsppath).include(request, response);

then I use that thread to do the calculations. I don’t mind tying up the webserver thread with this, but I want the browser to get the response and not wait for the server to close the socket.

I can’t tell if the server is closing the socket after the include, but I’m guessing it’s not.

So how can I forcibly close the stream after I’ve written out my response, before starting my long calculations?

I tried

o = response.getOutputStream();
o.close();

but I get an illegal state exception saying that the output stream has already been gotten (presumably by the jsp I’m including)

So my qestions:

  1. is the webserver closing the socket (I’m guessing not, because you could always include another jsp)

  2. if it is as I assume not closing the socket, how do I do that?

  • 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-14T18:08:51+00:00Added an answer on May 14, 2026 at 6:08 pm

    I don’t see how you can even close the OutputStream if the calculation is still going on in the same thread.

    You need to start the calculation in a new thread and just return from the Servlet and the response will be sent back automatically.

    If you really need to close the writer, do this,

      response.getWriter().close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a webpage that retrieves data (via ajax/php) and shows it in an
I have a webpage that receives AJAX data with values listing_id, lat, lng using
I have a main web page (Base Page) that makes an ajax call (using
I have a webpage that displays a very large list of data. Since this
I have a web app. that uses AJAX (via jQuery). I noticed that some
I have a PHP application that calls web services APIs to get some objects
On my webpage, I click on a button and it makes a ajax call
I have used a simple AJAX call in a webpage. he webpage is like
I have a webpage which when it is loaded makes an ajax request to
I have a webpage that shows some news, and a button that when is

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.