views:

34

answers:

2

I'm new in Java.

I'm trying to do

import org.apache.http.Header;
Header<NameValuePair> nvps = new HeaderList<NameValuePair>();
//....adding some headers
httppost.setHeaders(nvps);

but said

The type Header is not generic; it cannot be parameterized with arguments <NameValuePair>

how I can do it?

A: 

I've never used org.apache.http.* before, so I had a look at the API. From there I can see that Header is an interface and 'org.apache.http.message.BasicHeader' is one of its implementation. so maybe you'd like to use this type instead. Also I couldn't find HeaderList in the package.

sarahTheButterFly
A: 

I found the answer

Header[] headers = {
    new BasicHeader("Content-type", "application/x-www-form-urlencoded")
    ,new BasicHeader("Content-type", "application/x-www-form-urlencoded")
    ,new BasicHeader("Accep", "text/html,text/xml,application/xml")
    ,new BasicHeader("Connection", "keep-alive")
    ,new BasicHeader("keep-alive", "115")
    ,new BasicHeader("User-Agent", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2")
};