hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From AbelMacAdam <abel.maca...@gmail.com>
Subject RE: Check if user is logged in?
Date Fri, 25 Jan 2008 13:35:33 GMT

Hi Roland and others,

Thanks for the feedback. Would this help?
		HttpClient client = new HttpClient();
		// Sends uname/pword in clear text over Internet. Only use in debug mode
		Credentials defaultCredentials = new UsernamePasswordCredentials (uname,
		client.getState().setCredentials(AuthScope.ANY, defaultCredentials);
		client.getState().setCredentials(new AuthScope(HOST, PORT,
AuthScope.ANY_REALM), defaultCredentials);
// ======= New code ========================
		// TODO Check that a connection is made
		HttpMethod method = new GetMethod(HOST);
		if (method.getStatusCode() == 200) 
                     // We have a connection
// ======= New code ========================

I tried the addition of the last two lines. But it threw a
NullPointerException in

Might it be that at the moment I request the status code
(method.getStatusCode() ) the statusLine is not instantiated (yes, as this
is the definition of a NullPointerException)?


Roland Weber wrote:
> Hello Abel,
> That depends on the website to which you log in.
> Check if you get the page you would expect after
> logging in with a browser.
> hope that helps,
>   Roland

View this message in context: http://www.nabble.com/Check-if-user-is-logged-in--tp15062780p15087798.html
Sent from the HttpClient-User mailing list archive at Nabble.com.

To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org

View raw message