• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 26770
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic