Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6197897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:54:09+00:00 2026-05-24T03:54:09+00:00

For my java webapp, I would like a log-in form to appear on each

  • 0

For my java webapp, I would like a log-in form to appear on each (JSP) page if the user is not yet logged. Pages could be secure (HTTPS) or not (HTTP).

The log-in form must POST on a secured (HTTPS) URL to prevent the username/password to be sent in clear text.

If the user is currently on the page http://localhost:8080/app/home, using jstl [c:url value=”/login”] to compute the log-in form URL will not change the scheme from HTTP to HTTPS
(although /login is marked as CONFIDENTIAL in my web.xml).
Instead, it will give an URL like http://localhost:8080/app/login which will send a redirect to https://localhost:8443/app/login when accessed.
So why is the container redirecting instead of rewriting the URL to use the correct scheme (+ port) in the first place?

I could hardcode the log-in form secured URL but that would be less portable.

Or maybe, there are some considerations about web security I’m not aware of…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:54:10+00:00Added an answer on May 24, 2026 at 3:54 am

    When you use “/login” as the URL, the browser will interpret the URL as having the same hostname, port and scheme as the URL of the page containing the URL. If you want to use HTTPS, your server-side has to return HTML that uses URL with (at least) the “https:” scheme. This specified in the HTML spec.

    However, you don’t necessarily have to hard-wire the hostname into the JSP. The JSP could pick up the hostname from configuration property, or figure it out from the current request URL.


    But is there a standard way to ask the container (jetty, tomcat…) to convert “/login” into a full secure URL like localhost:8443/app/login ?

    AFAIK, no. (BTW, if there was Jetty or Tomcat specific way of doing this, it wouldn’t be standard …)

    The container is able to send a redirect to the right secure URL when I try to access the non-secure one, so why not skip the redirection part and make it produce the secure URL through response.encodeURL()?

    Good question.

    As I understand it, the feature that automatically incoming requests to a secure URL is container specific, and needs to be configured at the container level. Specifically, the container (or something) needs to be told what incoming URLs need this treatment. The JSP engine would need similar information to do the same thing when creating URLs for outgoing messages. AFAIK, there is no such facility in Tomcat’s JSP configurations.

    You’d need to ask someone on the JSR committee(s) that produced the Java EE specs for an answer as to why there is no standard way to do this.

    Even if I can figure the hostname out from the current request URL, I still have to know the HTTPS port (443? 8443?). If this port changes, it must be changed in both server and application config

    That is true, but changing a configuration parameter in two places is a minor thing.

    And like I said, if you have a beef with the various standards groups for not providing a standard solution for this … or with the Tomcat / Jetty implementors for not providing a non-standard solution … you should take this up with THEM.


    FWIW, I use a custom “secureURL” tag to solve this problem, but my use-case is significantly more complicated. I’m implementing components that can be dropped into existing sites and that need to work when https is available or is not available, and when secure cookies are used or not used … for example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a 10-year-old Java webapp, and I would like to introduce some
I'm looking for a good tool to profile a java webapp. I'd like to
I need to get UTF-8 working in my Java webapp (servlets + JSP, no
I got a bunch of servlet context listeners in my Java webapp, each of
I am beginning a new Java web application using Netbeans, and I would like
I would like to create a database backed interactive AJAX webapp which has a
I'm working on some Java <-> Perl interaction. I would like to know what
I have a WebApp with two dependencies as shown below. I would like to
We are currently working on a very simple Webapp, and we would like to
Hello I am a Java web app developer I have a problem, I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.