eppesuig
eppesuig

Reputation: 1385

Cookie usage in a Java application

I would like to use cookie in my java application. Looking at the Java API it seems there is no support of cookie in java.net package. The only support I found is about servlet, i.e., java.servlet.http.Cookie.

The only (minimal) support I found is in class java.net.CookieHandler, but it seems to be quite complex compared to java.servlet.http.Cookie management.

Thanks, Giuseppe

Upvotes: 0

Views: 1721

Answers (1)

Shivan Dragon
Shivan Dragon

Reputation: 15219

Using URLConnection you can get/add cookies by using the headers and adding request property "Cookie" respectively. This is native to Java SE. A 3rd party library that's also good is Apache's HttpClient/. The class you mention java.servlet.http.Cookie is only available to web-apps deployed in a Java EE Application server.

Upvotes: 1

Related Questions