The web.xml deployment descriptor can be used to enforce SSL or permit non-SSL by writing appropriate transport guarantees paired with URL
patterns. I'm not aware offhand of how application program logic could reliably determine whether the received URL came in via HTTP or HTTPS. By the time the app gets the data it's no longer encrypted (if it ever was) and I suspect that an "https" on the front of the URL can be faked, but with proper container enforcement, it doesn't matter.
URL patterns are WAR-relative resource patterns, meaning that the protocol, domain-name/ip, webapp context name, security credentials (where used), parameters and anchor offsets are all stripped off before matching. So for example, the URL
https://coderanch.com/mywebapp/jspcontroller/hellopart#paragraph_a?action=dothis&data=that would have a WAR-relative resource pattern match on "/jspcontroller/hellopart".
I do have JSPs that are not controller-backed, but that's because they're too trivial to have business logic in them. Stuff like "Hello" pages. So it's relatively easy for me to set up useful URL patterns. Apps that jump straight into heavy processing would need a Controller.
And yet one more reason why I encourage use of the built-in
J2EE container security over DIY login/access systems is that the container can handle all of this as a seamless
unit.