This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
i do not understand when is the cookie first created in the browser in the following code;
when we have forwarded the response to the resource , doesn't that mean the response has not yet been commited and hence the cookie should be created when the response is commited i.e when the jsp file is processed? or may be something else? i checked after i clicked submit in this, the cookie was created,iam little bit confused about working of request dispatcher,can anyone kindly explain ., thank you
Aashima Arora wrote:i do not understand when is the cookie first created in the browser
The cookie is not created in the browser; it is created in the server and stored in the browser. The server will encapsulate the cookie in a Set-Cookie response header. The server uses this header to ask the browser to store some state information locally. In this case, the server is asking the browser to store user information locally. If the browser decides to honour this server request i.e. if the user hasn't disabled cookies in his/her browser, then the browser will store the cookie locally. The browser will then send the cookie back to the server (in a Cookie request header) each time it communicates with the same server.
iam so sorry for the wrong question, i meant to ask when does the cookie first appear in the browser? i realize that there is a set cookie header in response and in the request here is a cookie header . in this particular code only, when the request has been forwarded to the jsp, when is the response being send back to the client .? is it when the jsp page appears so @ that very moment the cookie is stored .
in the jsp
when i click on 'click me'
iam redirected to
can i retrieve cookies on the jsp page itself or when i send the request from this page, i can retrieve cookies only on the checkcookie servlet?
Joined: May 13, 2002
when does the cookie first appear in the browser?
When the browser gets a response from the server. This response may come from a servlet or jsp.
can i retrieve cookies on the jsp page itself
When the user clicks a link on the jsp page, the jsp forwards the request to the servlet. At this point, the jsp can't access the cookies because the cookies haven't been created yet. After the servlet processes the request, the servlet may forward the request back to the same jsp page. At this point, the jsp may access the cookies.