Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

http/https switch

Status
Not open for further replies.

jack1971

Programmer
May 23, 2002
14
CA
I am trying to switch between http and https using jsp/servlet. Application server is Tomcat 4.1.18.

Say, I have a login page. When submitting the userid and password, I hope to switch to https (port 443 or 8443). Then the page will either stay with https or switch back to http (port 80 or 8080) depending on the user identity.

Jakarta site says they have turn to Struts, though this can be done with jsp/servlet. Based on my current deployment environment, I wish to solve this problem under jsp/servlet framework.

Anybody have any experience on this issue?

Thanks in advance!
 
I'm assuming you have a servlet running on port 80 (or 8080) and on port 443 (or 8443). Could you redirect the user using the "HttpResponse" object, and cause their browser to redirect to the correct port (based on the URL you responded with)?

Pete.


Lotus Notes Web Developer / Aptrix (LWWCM) Consultant
w: e: Pete.Raleigh(at)lclimited.co.uk
 
Thanks, Pete!

The problem is that if you redirect http to https (or reverse), you will get a new session, which results in the loss of the previous session, and all the objects bound to that session are reset to null. Then definitely you will get NullPointerException. If I force jsessionid=sesson.getId() to carry the sessionid to next page, only password and userid are accepted, while all the objects become null.

Do you have a piece of codes that I can take a look?

Jack
 
Could you dump all of the session information you need to a file (encrypted if necessary) and index it with the user's ID. Then when you redirect to the other port / servlet, restore the session information (if it exists) and continue processing.

Pretty cumbersome I know, but it's a thought. :)

Pete.


Lotus Notes Web Developer / Aptrix (LWWCM) Consultant
w: e: Pete.Raleigh(at)lclimited.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top