• Post Reply Bookmark Topic Watch Topic
  • New Topic

Enable JSESSIONID in url - How?  RSS feed

 
Nicky Formosa
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I know this might be strange but im looking for a way to enable the Jsessionid wihtin the url. How is that done? any ideas?

Thanks
Nick
 
Amol Nayak
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use either HttpServletResponse 's encodeUrl or endodeRedirectUrl (if redirecting) or use <c:url>
 
Nicky Formosa
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amol

Thanks for your reply.

Most of my responses are xml based and use the following:


or else redirect using the RequestDispatcher:


How can i do it in this way?

Thanks once again
Nick
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly why do you want to enable jsessionid? Or rather why do you want URL rewriting?
It is mostly used to maintain session when the client browser does not support cookies.

Have you looked up the API for methods suggested by Amol above?
 
Nicky Formosa
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amit,

You're absolutely right. The thing is that im creating a website for mobile viewing and since most of them do not support cookie i would need to hold the session somewhere..and since this jsessionid is there why shouldn't use it..the thing is..how! hehe


Regards
Nick
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nicky Formosa:
..the thing is..how! hehe


Have you looked up the API for methods suggested by Amol above?
 
Nicky Formosa
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I looked at the api's that amol told me about but to no avail. I tried using the follwing:

response.sendRedirect(response.encodeRedirectURL(url));

but still the url has no jsessionid. If it may be useful im using JBoss server 4.2.1.

Thanks
Nick
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
response.sendRedirect(response.encodeRedirectURL(url));


The encodeURL and encodeRedirectURL methods will only embed the session id if the container determines that it can't use another mechanism for maintaining state. Depending on the container, it may try to use cookies and/or SSL sessions first.

You may be able to force the issue by disabling session cookies, if your container has a configuration setting for this.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!