• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to return a parameter from a servlet to the calling HttpClient

 
starfish jellyfish
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am able to successfully post to a servlet using HttpClient. However i need a boolean parameter back to the HttpClient from the servlet and am not sure how to do the same.

Earleir i was using the common-httpclient-3.1.jar.However then i was made aware of the version upgrade of httpclient to 4.0 which assists in the Response handling from HttpResponse. Now I am using httpclient.4.0.3, httpcore-4.1 and httpmime-4.1.1. The code being tried by me is as below for the HttpClient.



In the KeyStoneServlet i am able to successfully get the parameters directory, username and password. Further using these parameter am doing a further processing and am able to retrieve a boolean parameter which i want back as a response to the HttpClient. However i do not know how can i do the same. The responseBody SOP above comes blank and doesnt show me anything.

In the servlet the parameter i need is mentioned in the below code.



I am unable to understand how should i send this back to the calling httpclient. I understand that i can create a BasicHttpParam in the servlet and use the setBooleanParameter routine. But i cant retreive this param in the calling httpclient.

The SOPs above where i am trying to retrive the params come out blank. Since the SOP for Params returns the defaultValue, it prints out false. The responseBody SOP always comes up as blank

Any immediate assistance on the same will be highly appreciated.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This servlet side code:



is obviously using some sort of library NOT part of the standard servlet API. Surely the place you should be looking for an answer is the documentation for that library.

A brief search indicates HttpParams are in the Apache httpcomponents library.

Bill
 
starfish jellyfish
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Will,

I do have httpcore-4.1.jar in my lib. This has the HttpParams as well as the BasicHttpParams class files in them. Do assist me with the same.

Thanks,
starfish
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I never heard of HTTP response parameters before. And I don't see any "setParameter" method in the HttpServletResponse specs either. Normally what people do is to parse the HTTP response to extract the data they need.
 
starfish jellyfish
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:I never heard of HTTP response parameters before. And I don't see any "setParameter" method in the HttpServletResponse specs either. Normally what people do is to parse the HTTP response to extract the data they need.


Hi Paul,

I am not mentioning regarding HttpServletResponse. The servlet is being called by a HttpClient and i was looking for a way to read through a boolean parameter which is a response from the servlet to the HttpClient.

I found the needful. Thanks everyone for the assistance. :)

Regards,
starfish
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic