httpclient authentication

R

ravi

hi,

i am using org.apache.commons.httpclinet api to authenticate the
server.

i am using the following code.

client.getState().setCredentials("FORM","http://localhost:8080/admin",
new UsernamePasswordCredentials("username","pwd"));

GetMethod get = new
GetMethod("http://localhost:8080/admin/frameset.jsp");

get.setDoAuthentication( true );

int status = client.executeMethod( get );

System.out.println(status + "\n" + get.getResponseBodyAsString());

instead of getting the frameset.jsp i am getting the login.jsp.I
don't whether
it is authentication failure or not. can someone help me on this.

regards
ravi
 
H

Holla

ravi said:
hi,

i am using org.apache.commons.httpclinet api to authenticate the
server.

i am using the following code.
instead of getting the frameset.jsp i am getting the login.jsp.I
don't whether
it is authentication failure or not. can someone help me on this.

regards
ravi

I assume that your 'client' is of type HttpClient. Did you tried to send
preemptive Authentication?
i.e. before calling executeMethod() of client, set client premptive
authentication to true.

like this,

client.getState().setAuthenticationPreemptive(true);

Then call executeMethod. With this your credtential sent along with the
request. Hence you webserver(application server/JSP serever) doesn't
sends/redirect you to redirect page, if supplied creditential is okey.

regards

Holla
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top