Why is my session id in my url?

12,172

Solution 1

This is standard JavaEE behavior, and is dictated and controlled by the servlet container. It has nothing to do with Spring.

See this previous question to find out why and when it gets created, and how to avoid it.

Solution 2

I didn't see this answer in the other question so I wanted to explain it. The way sessions work in java and I think php, is when the client first comes it, it creates a cookie and appends JESSIONID to all the urls that used <c:url/> tag. The reason it does this is because the first time the client visits the page, the server has no idea if the client supports cookies. So it does both. Next time, since it sees the cookie, it will actually not use URLs anymore because it knows cookies worked.

There is a lot of ways to disable this. If you are not using sessions at all then you can disable cookies by putting cookies=false in context.xml. This only disables cookies for the session and not regular cookies. You can then use urlrewrite to stip the sessionid.

Hope that helps.

Share:
12,172
Samo
Author by

Samo

I'm a software consultant in the twin cities, specializing in Ruby on Rails, PostgreSQL, and JavaScript. I also play blues, jazz, and klezmer saxophone and enjoy a chess game on occasion. I spend most of my off time with my wife and kids.

Updated on June 04, 2022

Comments