i need to make the URL for my form action but the form should be submitted under https
currently the underlying system running on 9002 port for the HTTPS.I can not use the following option in my JSP page
<form:form action="${request.contextPath}/springSecurity/login"
method="post" commandName="loginForm" target="guestFrame">
since when in HTTP the context path is coming as HTTP and the system will throw an exception as form should be submitted by HTTPS.
i can not hard code the action URL as currently its under develoment as the host name is localhost
, even the HTTPS port is configurable so its even can not be hard-coded.
Is there any way i can create the URL in my JSP using JSTL or any other way so as to i can submit the form under HTTPS
HttpServletRequest.getServerName()
will give the server name. But, there is no way to get thehttps
port. You should be using the default443
if you want to fix it in your approach.But the good solution is to use the
Security Transport Guarantee
for the login url, such that the server will automatically redirect thespringSecurity/login
page tohttps
.Add this entry to the
web.xml
which will automatically redirect thespringSecurity/login
tohttps
.