• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java ArrayList into Name value pair

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a java class, am using an arraylist say reports containing list of all the reports which have reportid, reportname, reporttype etc which i want to add into NameValuePair and send a Http postmethod call to a particular url.

I want to add the arraylists - reportname into name value pair(org.apache.commons.httpclient.NameValuePair) and then use the http client post method to submit the name value pair data to a particular url.

Here is my name value pair






please suggest me how to add the reports arraylist reportname into reports field of NameValuePair.

--
thanks
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sangram nani wrote:please suggest me how to add the reports arraylist reportname into reports field of NameValuePair.


It strikes me that what you do is likely to be dictated by what the target of your HttpPost expects. Do you know that?

Winston
 
sangram nani
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:

sangram nani wrote:please suggest me how to add the reports arraylist reportname into reports field of NameValuePair.


It strikes me that what you do is likely to be dictated by what the target of your HttpPost expects. Do you know that?

Winston




i will be using this name value pair to call a http postmethod to a salesforce URL so that the details of name value pair are stored in the salesforce site as a lead.
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sangram nani wrote:i will be using this name value pair to call a http postmethod to a salesforce URL so that the details of name value pair are stored in the salesforce site as a lead.


Yes, but what does that salesforce URL expect? Because that will govern what you put into your NameValuePair instance(s).

Winston
 
sangram nani
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:

sangram nani wrote:i will be using this name value pair to call a http postmethod to a salesforce URL so that the details of name value pair are stored in the salesforce site as a lead.


Yes, but what does that salesforce URL expect? Because that will govern what you put into your NameValuePair instance(s).

Winston




Here is the code am using to send the data to sales force url along with the salesforce access credentials in the data variable. The sales force url has servlet namespace,.

for (NameValuePair nameValuePair : Data) {
postData[count] = nameValuePair;
count++;
}
post.setRequestBody(postData);
BufferedReader in = null;
try {
int returnCode = client.executeMethod(post);
in = new BufferedReader(new InputStreamReader(
post.getResponseBodyAsStream()));

String inputLine;


while ((inputLine = in.readLine()) != null) {


response+=inputLine;
System.out.println(inputLine);
}
in.close();
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sangram nani wrote:Here is the code am using to send the data to sales force url along with the salesforce access credentials in the data variable. The sales force url has servlet namespace,


I don't think you quite understand. You asked how to convert an ArrayList of reports to name/value pairs; what you have given me is the code to put those pairs into a request.

The question you need to answer is: what does your URL expect?
Is it it the name "report", followed by a comma-delimited list of report names as the value? Or is it a whole slew of NameValuePair objects of the form:
reportname=report1
reportid=1
reporttype=big
reportname=report2
reportid=2

...
The answer will determine what you need to do, but only you can answer that question.

Winston

Having thought about it, another option might be:
reportnames=report1,report2,...
reportids=1,2,...
reporttypes=big,small,...

but you still have to know what it is.

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic