• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How is jsessionId handled when moving from http --> https?

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's say that I've never visited a site, and I go to it using http://mysite.com.

The servlet container is supposed to assign a jsessionId and try to set a cookie. If I have cookies enabled, I should no longer see the jsessionId, correct?

Now, what happens when I redirect (or forward) from a page on http://mysite.com/servlet1 to another https://mysite.com/servlet2? Will URL rewriting kick in? Will the SAME sessionId be used (and is this good practice in terms of security?)

If URL rewriting does kick in for the scheme change (http --> https), should i expect it to break my URLs by adding the ";jsessionId=xxxx"? and what can I do to prevent this? (servlet filter to intercept and strip this out)?

I would even appreciate an RTFM reference if this is too basic.

thanks in advance.

_R
 
Rex Norm
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry one more question to be complete-- is the behavior different when coming from https:// and redirecting (or forwarding??) to http://?

that is, is jsessionID (URL rewriting) used in the reverse direction or can the cookie be used? Can I force this?

thanks,

_r
 
Ranch Hand
Posts: 144
Oracle Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should never perform url rewriting yourself since they container can do it if you tell it to. If you are creating URLs in a Servlet, you should use the javax.servlet.http.HttpServletRequest encodeURL method. In a JSP you should use the JSTL url tag <c:url> example. These will automatically perform url rewriting if needed. If you use encodeURL or url tags anytime you have a link then you should be set.
 
Rex Norm
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mike, thanks for your response.

You should never perform url rewriting



I plan to avoid this.

If you are creating URLs in a Servlet, ...


yes, this is my intent... I need to redirect from an insecure page to a secure login page (SSL) and then redirect to another secure page on success.

...you should use the javax.servlet.http.HttpServletRequest encodeURL method. In a JSP you should use the JSTL url tag <c:url> example.


So does this mean that the same sessionId is used for both http and https? Meaning that a redirect from http --> https will be handled by the tag and container? I seemed to read somewhere that setting a new sessionId is a good idea for the secure component. I guess nothing is preventing me from setting a new cookie with a new (self generated) ID with quick expiration for the secure part and relying on that, right?

Also, is there a difference between <html:link> and <c:url>? do they do the same thing?


thanks for your help.
_R
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<html:link> is a proprietary struts tag.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic