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?
Community
  • 1
  • 1
Neel
  • 2,100
  • 5
  • 24
  • 47

1 Answers1

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

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
  • 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? – Neel Apr 17 '12 at 20:26