Skip to content

Instantly share code, notes, and snippets.

@hotcoder
Last active August 29, 2015 14:01
Show Gist options
  • Save hotcoder/8f74d9b7050099cb3c4a to your computer and use it in GitHub Desktop.
Save hotcoder/8f74d9b7050099cb3c4a to your computer and use it in GitHub Desktop.
cookie handling
<%
Map<String,String> s = new HashMap<String,String>();
Cookie cookie = null;
Cookie[] cookies = null;
// Get an array of Cookies associated with this domain
cookies = request.getCookies();
if (cookies != null) {
out.println("<h2> Found Cookies Name and Value</h2>");
for (int i = 0; i < cookies.length; i++) {
cookie = cookies[i];
s.put(URLDecoder.decode(cookie.getName(),"UTF-8"),URLDecoder.decode(cookie.getValue(),"UTF-8"));
//out.print("Name : " + URLDecoder.decode(cookie.getName(),"UTF-8") + ", ");
//out.print("Value: " + URLDecoder.decode(cookie.getValue(),"UTF-8") + " <br/>");
}
} else {
out.println("<h2>No cookies founds</h2>");
}
session.setAttribute("comap", s);
%>
Babu : <c:out value="${comap['a bc']}"/>
<c:set var="comap" value="" scope="session"/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment