I need to change cookies value of another domain, I know that we can not do it using javascript. Is it possible using servlet ?
I am trying like this but no success? were am I going wrong? I have two web application namly Cookies1 and Cookies2 deployed in one tomcat in localhost
Servlet of cookie1 application
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
// String Html = "<HTML><BODY>HI</body></html>";
// pw.write(Html);
Cookie cookie = new Cookie("__utmz", "Arvind");
cookie.setDomain("http://localhost:8080/Cookie2");
cookie.setPath("/");
response.addCookie(cookie);
//response.getWriter().write(Html);
}
Servlet of cookie1 application
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
System.out.println("CookieSetDm.doGet()");
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
System.out.println(cookies[i].getName() + " <> "+ cookies[i].getValue());
}
}
}