Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to retrieve HttpResponse Headers

 
Sudhakar Krishnamurthy
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings:
Is their a possibility to retrieve the headers from HttpResponse, i know we can retrieve it from the HttpRequest but i need it from the HttpResponse.
Here's why i need to retrieve the response header:
I have a servlet A running on my local machine that needs to send an object to servlet B that is running on a remote machine as a post message. for servlet B to accept the post message i need to send the cookie(generated by serlvet B) in the post message.
Any help is greatly appreciated.
-Sudhakar
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't you just forward the request to servlet B? Am I missing something here?
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can only use forward() to something in your own web app.
Kyle
 
Sudhakar Krishnamurthy
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no i can't forward the request to servlet B since servlet B is on a remote machine and even if it were i don't want to because i need the response from servlet B to be processed by servlet A.
I am using oreilly's HttpMessage.sendPostMessage(obj) method to perform a post on the remote machine, this returns me an inputstream that contains the response, i am trying to figure out if this response will contain the header info, if so then i can parse the response to retrieve the info needed. Is their a better way to do this??
Any suggestions??
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whenever I need to send a request to another server and receive and parse the response, I use HTTP Unit
This software offers methods to simply fetch headers from a returned response:

Maybe that might be easier?
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep! I missed the fact that servlet B resides on a remote machine.
[ January 09, 2004: Message edited by: Bosun Bello ]
 
Sudhakar Krishnamurthy
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the response Frank, but i don't have the liberty to use this software, i am bound to use custom made classes or oreilly only.
Any suggestions??
Thanks,
-Sudhakar
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In which case I suggest you download the source code for HTTPUnit, and use any bits you like in your "custom code". That's the beauty of open source.
Although limiting oneself to just one, limited, open source package, rather than using whatever is most suitable does seem a bit pointless.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic