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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:54:12+00:00 2026-05-22T11:54:12+00:00

I found a segment of java code that is claimed to return object using

  • 0

I found a segment of java code that is claimed to return object using ObjectOutputStream

     OutputStream outstr = response.getOutputStream();
     ObjectOutputStream oos = new ObjectOutputStream(outstr);

     oos.writeObject(process);

     oos.flush();
     oos.close();

response is a HttpServletResponse object. I would like to know how this segment of code works, and how to test it?

  • 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-22T11:54:12+00:00Added an answer on May 22, 2026 at 11:54 am

    Below is a simple example that shows how to read a serialized object via HTTP.

    import java.net.URL;
    import java.net.HttpURLConnection;
    import java.io.ObjectInputStream;
    
    /**
     * This is a simple example to read an object. 
     *
     * This is not production ready code ;-)
     */
    public class Sample {
    
        public static void main(final String [] pArgs) throws Exception {
    
            // Change SERVER:PORT/PATH to match your application.
            final URL url = new URL("http://SERVER:PORT/PATH");
            final HttpURLConnection conn = (HttpURLConnection)url.openConnection();
    
            conn.setRequestMethod("GET");
            conn.setReadTimeout(10000);
            conn.connect();
    
            final ObjectInputStream is 
            = new ObjectInputStream(conn.getInputStream());
    
            final Object obj = is.readObject();
    
            if (obj instanceof String) System.out.println((String)obj);
            else // Convert to object and do whatever.
    
            is.close();
            conn.disconnect();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found this open-source library that I want to use in my Java application.
i need to segment an image into regions .i'm using pil.i found no module
After porting a code segment from Windows to Mac OS X, I found it
Found some old code, circa VS 2003. Now I have just VS 2008 (SP1)
Found the following in an Oracle-based application that we're migrating (generalized) : SELECT Table1.Category1,
Anybody found yet a good web site architecture using linq to sql? Any help
I need to segment text using fullstops using PHP/Javascript.The problem is if I use
I have this segment of code , a lot of things skipped for brevity
I have found this link: Detect Antivirus on Windows using C# However when I
I have this algorithm that I found here, just one thing puzzles me about

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.