Wednesday, 15 May 2013

java - Format servlet cookie to http-friendly format -



java - Format servlet cookie to http-friendly format -

given javax.servlet.http.cookie object, there method somewhere can format cookie http friendly format can send in response? likewise, given cookie header in request, there method parse cookie javax.servlet.http.cookie object? i've looked on couldn't find method that.

thanks!

you can utilize httpcookie class own implementation. utilize tostring() function

constructs cookie header string representation of cookie, in format defined corresponding cookie specification, without leading "cookie:" token.

after add together header set-cookie:the_to_string_value response , that's it.

for reading cookies need parse headers.

java http servlets cookies

No comments:

Post a Comment