Mar 11

How to get cookie value in Java

Cookies come as part of the HttpServletRequest object. ┬áThe below code should help you retrieve cookie values that you have set on a client’s browser.


Cookie[] cookies = servletRequest.getCookies();

if (cookies != null) {
 for (Cookie cookie : cookies) {
   if (cookie.getName().equals("cookieName")) {
     //do something
     //value can be retrieved using #cookie.getValue()

Mar 11

Deleting a remote git branch

Yeah, so I’ve been using git from a few months now and I must say, compared to the other version controls, this has given me the most pain. But, that doesn’t mean I don’t like git or won’t use it. In fact I now prefer git over the other version controls out there.

I recently had to delete a remote git branch. After some search found that the command to do this is :

git push origin :branch-name

Of course, you would still need to delete your local git branch using

git branch -d branch-name

Update April, 2011: You can also delete a remote branch in Git using the command below:

git branch -d -r origin/branch-name