0

I have an application running on localhost:8080 and it create a cookie with name jsessionid. Now I need to open another tabs for different application which is running on localhost:8090 which also create a cookie with same name that is jsessionid.

I need to access cookie of first application tab in second application tab..

how can I access both cookies... many tried but no luck...

Cœur
  • 37,241
  • 25
  • 195
  • 267
Ashwani Verma
  • 39
  • 1
  • 11

2 Answers2

0

You can write a servlet filter that would run before page gets rendered (in the atlassian-plugin.xml)

<servlet-filter name="My Filter" i18n-name-key="home-page-redirect-filter.name" key="home-page-redirect-filter" class="mypackage.CookieFilter" location="before-dispatch" weight="100"> <description key="home-page-redirect-filter.description">Some description</description> <url-pattern>WHEN_TO_RUN</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </servlet-filter>

and then you can intercept cookies

public void doFilter(ServletRequest req, ServletResponse resp,
        FilterChain chain) throws IOException, ServletException {
    HttpServletRequest request = (HttpServletRequest) req;
    Cookie[] myCookies=request.getCookies();
    //do something with cookies
}
Panos Karampis
  • 557
  • 6
  • 18
  • Hi Panos.. thanks for your fast reply, implement as you suggest me but still not getting previous application tab **(localhost:8080)** cookie, i think its becouse of request object which is requesting from **localhost:8090**... how can i get it from browser.... – Ashwani Verma Aug 27 '15 at 06:06
  • having **context path** for both the appliaction.. will it help in getting cookie.. – Ashwani Verma Aug 27 '15 at 06:37
0

Looks like I misread your question. JSESSIONID is an httponly cookie and you won't be able to use document.cookie in the javascript to get it. Maybe take a look at Jsoup Cookies for HTTPS scraping and Sending POST request with username and password and save session cookie for some ideas.

Community
  • 1
  • 1
Panos Karampis
  • 557
  • 6
  • 18