*/
public HttpSessionCookie getSessionCookie()
{
if (getConfiguration() == null)
{
throw new ChainedRuntimeException("setConfiguration() should have "
+ "been called prior to calling getSessionCookie()");
}
ConnectionHelper helper = ConnectionHelperFactory.getConnectionHelper(
((WebConfiguration) getConfiguration()).getRedirectorURL(this),
getConfiguration());
WebRequest obtainSessionIdRequest = new WebRequest(
(WebConfiguration) getConfiguration());
//Not sure whether I should be adding the service parameter to
//this request (this) or to the obtainSessionIdRequest
//seems obvious that it should be the obtainSessionIdRequest
RequestDirectives directives =
new RequestDirectives(obtainSessionIdRequest);
directives.setService(ServiceEnumeration.CREATE_SESSION_SERVICE);
HttpURLConnection resultConnection;
try
{
resultConnection =
helper.connect(obtainSessionIdRequest, getConfiguration());
}
catch (Throwable e)
{
throw new ChainedRuntimeException("Failed to connect to ["
+ ((WebConfiguration) getConfiguration()).getRedirectorURL(this)
+ "]", e);
}
WebResponse response;
try
{
response =
(WebResponse) new WebResponseObjectFactory().getResponseObject(
WebResponse.class.getName(),
obtainSessionIdRequest,
resultConnection);
}
catch (ClientException e)
{
throw new ChainedRuntimeException("Failed to connect to ["
+ ((WebConfiguration) getConfiguration()).getRedirectorURL(this)
+ "]", e);
}
Cookie cookie = response.getCookieIgnoreCase("jsessionid");