Question

I am facing a problem while retrieving cookie over https for an application deployed on weblogic. I am using below code.

HttpURLConnection huc3= (HttpURLConnection) new URL(url1).openConnection();
huc3.setRequestMethod("POST");
BufferedReader in = new BufferedReader(
    new InputStreamReader(huc1.getInputStream()));

huc3.setDoOutput(true);
DataOutputStream wr3 = new DataOutputStream(huc3.getOutputStream());
wr3.writeBytes("Username=abc&password=xyz");
wr3.flush();
wr3.close();

String thirdCookie = huc3.getHeaderField("Set-Cookie");

Problem here is, I am able to retrieve "JSESSIONID", but I am not able to retrieve "_WL_AUTHCOOKIE_JSESSIONID". Which is secure cookie and required to make subsequent authenticated call.

I application deployed over weblogic doesn't have https enabled, then only JSESSIONID is generated on authentication, and works fine.

But on HTTPS it generate another cookie which I am not able retieve.

If I use cookie manager and do in a standalone application

CookieManager cookieManager = new CookieManager();
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(cookieManager);

it works fine. But i have following questions:

1.I want to know how to extract "_WL_AUTHCOOKIE_JSESSIONID" with out using CookieManger?

2: is, if I put this code in web application and deploy on weblogic, it stops working. Why?

Was it helpful?

Solution

Found solution to second problem. Basically we have to set a java option in "startWebLogic.cmd" to tell weblogic not to use Weblogic's httphandler, use handler come with sun. Weblogic's httphandler doesn't seem to be utilizing CookieManager and CookieHandler.

I set below option.

set JAVA_OPTIONS=%JAVA_OPTIONS% %JAVA_PROPERTIES% -DUseSunHttpHandler=true - Dwlw.iterativeDev=%iterativeDevFlag% -Dwlw.testConsole=%testConsoleFlag% -Dwlw.logErrorsToConsole=%logErrorsToConsoleFlag%

Still looking for answer of question 1.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top