THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
You can retrieve cookies from the WebRequest
object, that can be retrieved from the RequestCycle
.
Quick hint: RequestCycle
can be obtained by calling Component#getRequestCycle()
or anywhere on the thread, that is responding to a web-request by calling RequestCycle.get()
.
Code Block |
---|
WebRequest webRequest = (WebRequest)RequestCycle.get().getRequest(); // Variant A: You can ask for specific Get cookie bywith itsspecified name Cookie cookie = webRequest.getCookie("cookieName"); // Variant B: YouGet can get all cookies at once List<Cookie> cookiesList = webRequest.getCookies(); |
...
You can ask web-browser to store cookies, by adding cookie into the WebResponse
object, that can be retrieved from the RequestCycle.
Code Block |
---|
//WebResponse Create cookie Cookie cookie = new Cookie("cookieName", "cookieValue"webResponse = (WebResponse)RequestCycle.get().getResponse(); // AddCreate cookie and add it to the response WebResponseCookie webResponsecookie = new (WebResponse)RequestCycle.get().getResponse(Cookie("cookieName", "cookieValue"); webResponse.addCookie(cookie); |
...