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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:45:33+00:00 2026-05-24T09:45:33+00:00

I made a simple server written in java which simply sends the html code

  • 0

I made a simple server written in java which simply sends the html code of an html file to any client that connects to it. It uses port 8008. The problem is when I use chrome to get this html via http://localhost:8008, it does not seem to work. What should I do for the two to communicate properly and for the browser to render the html page. I am using ServerSockets. Also, how can a web browser send information or request to the server? Any ways using the url? THanks!

    ServerSocket serverSocket = null;
    try {
        serverSocket = new ServerSocket(8008);
    } catch (IOException e) {
        System.err.println("Could not listen on port: 8008.");
        System.exit(1);
    }

    Socket clientSocket = null;;
    try {
        clientSocket = serverSocket.accept();   //This is the browser requesting for connection
    } catch (IOException e) {
        System.err.println("Accept failed.");
        System.exit(1);
    }

    PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
    BufferedReader in = new BufferedReader( new InputStreamReader( clientSocket.getInputStream() ) );

    out.println("Some HTML Code");  //The browser should be able to render the HTML Code sent

    out.close();
    in.close();
    clientSocket.close();
    serverSocket.close();
  • 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-24T09:45:33+00:00Added an answer on May 24, 2026 at 9:45 am
    The server you've developed is **not a web server**, right? The server you've developed **cannot handle HTTP requests**(used Sockets), but unfortunately the 
    

    browsers would use protocols (say, HTTP) to access files over network

    .

    You’re expecting the result through wrong process. I would say develop a client Java program, which should connect to the port you mentioned with your ServerSocket initialization.

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

Sidebar

Related Questions

I've made a simple http server using Twisted, which sends the Content-Type: multipart/x-mixed-replace header.
I've made a simple dummy server/dummy client program using IOCP for some testing/profiling purpose.
I have a very simple server written in C and an equally simple client
I have a simple HTML server program that listens on port 8000 for a
I'm trying to make a simple HTML server that will read a request from
We made a simple application and using GoogleAppEngineLauncher (GAEL) ran that locally. Then we
For an assignment I've made a simple C++ program that uses a superclass (Student)
I have made my own file type (.ddd) and I made a simple program
Made a simple server using TcpListen and would like to add SSL to the
i made simple web server like below. import BaseHTTPServer, os, cgi import cgitb; cgitb.enable()

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.