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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:55:18+00:00 2026-06-15T06:55:18+00:00

I build a Web Server in java, which I get request (as a socket)

  • 0

I build a Web Server in java, which I get request (as a socket) and process it.
I am required to first print the entire request and then process it on.
Here’s my code snippet:

public HttpRequest(Socket socket) throws Exception
{
    this.socket = socket;
    BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
    printRequest(input);
    // Do More...
}

The problem is that from this point on, the BufferedReader is in its end and I can’t seem to find a way to get it back to the beginning. The printRequest() method prints the entire request from the BufferedReader with a while loop and readline() actions).

Any ideas how I can fix this?

  • 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-06-15T06:55:20+00:00Added an answer on June 15, 2026 at 6:55 am

    You can read the content in a byte array, and then use ByteArrayInputStream any time you neeed it:

    InputStream is = socket.getInputStream();
    byte[] content = new byte[is.available()];
    is.read(content);
    printRequest(new BufferedReader(new InputStreamReader(new ByteArrayInputStream(content))));
    processRequest(new BufferedReader(new InputStreamReader(new ByteArrayInputStream(content))));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to build Android application using Java which is able to send request
I'm trying to build a simple web server in Java as practice but I'm
I'm trying to build a web server in node.js that will support cross-domain scripting,
I've added a pre-build action for an ASP.NET web control (server control) project, that
I build a Web Service in ASP.Net which sends me a list of rooms.
I have an existing Java client that I need to build a web service
I want to build a stateless web application using Java Servlets. Because it's stateless,
I'm developing a Java server application with Eclipse Indigo, which is deployed to Jetty.
I have to build a multibrowser web app which should be able to be
Here's the problem: I have a java dynamic web project under source control and

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.