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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:45:19+00:00 2026-05-27T10:45:19+00:00

I am trying to make a web chat to integrate with other languages. I

  • 0

I am trying to make a web chat to integrate with other languages.
I am willing to create my own webserver in java.. that knows only to respond to a specific request.

I have a socket that is listening to port 80. answering with

out.print("HTTP/1.1 200 OK\r\n");
out.print("Content-Type: text/plain\r\n\r\n");

out.println("We have a text now");

out.print("\r\n");
out.print("\r\n");
out.print("0");
out.print("\r\n");
out.print("\r\n");

My problem is… is there any way to use partial response to keep the browser’s socket open?

I want to send the messages only when they exist.. in this case messages will be sent almost instantly..

P.S: I am not talking about web-sockets because not all programs support web-sockets… only browsers do… (programs that don’t support web-sockets: Internet Explorer)

My question is if I can use partial response (206) in this case.. and how to keep the page “loading” and also send partial text… ??… Do I have to say content-length or something? what header do I have to write… I know only for several statuses (200, 301, 404, etc). For 206 I don’t know what to write on first, second, third line.. how to send the response (as xml, text, or can I define content type?) and how to read it from javascript?

For example I want this code to write every second something:

out.print("HTTP/1.1 200 OK\r\n");
out.print("Content-Type: text/plain\r\n\r\n");

for (int i = 0; i < 10; i++)
{
    out.println("We have a text now");
    try
    {
        Thread.sleep(1000);
    }
    catch (InterruptedException e)
    {
        e.printStackTrace();
    }

}

out.print("\r\n");
out.print("\r\n");
out.print("0");
out.print("\r\n");
out.print("\r\n");

Regards

  • 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-27T10:45:19+00:00Added an answer on May 27, 2026 at 10:45 am

    Any decent http client will use http keep-alives, so if a user makes a request again within a few seconds they will not need to open a new connection. If you write your own web-server you will have to make sure to implement this or the implementation will be slower than a standard web server or web container (e.g. tomcat or jetty). Also, since many languages have good http libraries, you don’t need a custom implementation of a web server for this either.

    If you’ve written a servlet, it is possible to simply never return from the http response and then just write responses out as they come. This will tie up threads on the server though and probably won’t scale very well.

    You could try one of the asynchronous http implementations (e.g. netty or mina) and have a go at it, but that is significantly more work — although it would still be far less work than trying to roll your own.

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

Sidebar

Related Questions

I'm trying to make a web page that only has content within the page
I am trying to make a web app in Dashcode that uses a range
I'm trying to make a web scraper that will parse a web-page of publications
I am trying to make my web app compatible with international languages and I
I'm trying to make a simple C# web server that, at this stage, you
i'm trying to create a bridge program in twisted.web that receives data from a
I am trying to make a web part that will display what links got
I'm trying to make a web app that will read in a server-side CSV
I'm trying to make a web app that will manage my Mercurial repositories for
Hello I'm trying to make a simple web chat, and I want the user

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.