I have two applications running in Jboss, can I write a cookie in a application and read in another?
For example, if I have two Servlets:
– WriterCookieServlet on localhost:8080/Application1
– ReaderCookieServlet on localhost:8080/Application2
WriterCookieServlet:
Cookie cookie = new Cookie("cookie", "cookieValue");
response.addCookie(cookie);
response.sendRedirect("localhost:8080/Application2");
Then on ReaderCookieServlet I want read this cookie.
I think @galuano1 is right: this should indeed be possible. Make sure the path is correct, though. It is used to determine whether a certain cookie is visible to a web-application.
From the Cookie Javadoc:
I’d say you should use
/for directory, since both applications will have a different context root.