Friday, October 26, 2007

Switching between HTTP and HTTPS protocols HTML

In HTML when we provide link to internal pages using href (same is valid for other tags like img, form etc) we use relative/absolute path in the form of 'abc.jsp' or '/abc.jsp'
However we may want to switch the protocol (from HTTPS to HTTP for example) for the new link.
This is not possible without using complete URL ('http://mydomain/abc.jsp'). Using complete URL is not a good thing to do as the domain mane may vary and presence of proxies.
Now you have to generate the complete URL on the fly either at server side (if you are using Servlet/JSP) or at client side using javascript.
It is strange that HTML doesn't have a syntax for specifying the protocol for relative paths

3 comments:

Unknown said...

I think you are confused between absolute & relative paths. Read this document

BTW. why should the browser be sent the protocol for a href / src? It will use the current URI for the protocol.

Rejeev Divakaran said...

Praveen,
Assume you some pages (eg: payment page) with transport garantee confidential. All other pages with 'NONE'. How will you enforce transitioning from HTTPS to HTTP after the payment page?

Protocol Testing Training Bangalore said...

Thank you for the great web site - a true resource, and one many people clearly enjoy thanks for sharing the info, keep up the good work going....