You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by AbelMacAdam <ab...@gmail.com> on 2008/01/24 12:05:13 UTC
Check if user is logged in?
Hi,
After the user has logged in, what check can I perform to see whether the
user is actually logged in?
I want to perform a check to see if logging in succeeded before I execute
the next step. (*Cant have executing the next step while the user entered a
wrong password of something like that*).
Abel
--
View this message in context: http://www.nabble.com/Check-if-user-is-logged-in--tp15062780p15062780.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
RE: Check if user is logged in?
Posted by AbelMacAdam <ab...@gmail.com>.
Hi Roland and others,
Thanks for the feedback. Would this help?
[code]
HttpClient client = new HttpClient();
// Sends uname/pword in clear text over Internet. Only use in debug mode
Credentials defaultCredentials = new UsernamePasswordCredentials (uname,
pword.toString());
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 ========================
[/code]
I tried the addition of the last two lines. But it threw a
NullPointerException in
org.apache.commons.httpclient.HttpMethodBase.getStatusCode
(HttpMethodBase.java:570)
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)?
TIA,
Abel
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