0

I found a couple of questions somewhat related to this:

httpclient-request-set-attribute-question
commons-httpclient-adding-query-string-parameters-to-get-post-request

but I think I am trying to do something different here: I have a servlet which will set an attribute into the request. In my Java client, I am using HTTP Components library, and I want to read the attribute in my client.

  1. Is this an invalid use case for the HTTP Components library?
  2. If not, one way would be to serialize the object in the servlet and de-serialize it back in the client, but I am not sure if that is the best practice.
  3. Is there an API I am missing here?

1 Answer 1

1
  1. Request attributes are not accessible to the client.

  2. You should send them as response somehow (write them as key-value pairs, serialize the object graph with JSON, etc.). So yes, that's the accepted practice

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Bozho! So, in order to serialize the object, I can still use a DataOutput stream in order to write out to the response, then read it back as an object, right?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.