Santosh Gdr
Santosh Gdr

Reputation: 65

How to handle the session in HttpUnit

try{
        HttpEntity entity=null;
        HttpGet httpget=null;
        HttpResponse  response=null;

        httpclient = new DefaultHttpClient();

        httpget = new HttpGet(credentialsURL);

        httpget.setHeader(HttpHeaders.USER_AGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.120 Safari/535.2");
            response = httpclient.execute(httpget);

            entity = response.getEntity();

                if (entity != null) {

                    EntityUtils.consume(entity);
                }
        }
        catch(Exception e){

        }
        return httpclient;

I am using HttpClient to handle session.Here is my code to handle session using httpclient. But httpclient won't handle ajax calls. I am planning to move to httpunit to overcome my problem. Basically I have a referral URL(or authentication server) from which I need to get cookies and session and store it in client. And use this client across website to get logged user information. What is the appropriate solution for this using httpunit. credentialsURL="https://www.,,,,.com./sapLogin.aspx?HOOK_URL=https://authentication.server.address&username=&password= ";

Upvotes: 1

Views: 265

Answers (0)

Related Questions