Use relative path for form actions in JSP
11,418
Solution 1
You can just dynamically print the context path as follows:
<form action="${pageContext.request.contextPath}/alterPassword" ...>
Or use the HTML <base>
tag so that all relative links in the page are relative to it.
See also:
Solution 2
You can use ../
or use context path as follows
<form action="/<%=request.getContextPath()%>/alterPassword" id="changepassword" method="post"
autocomplete="off" onsubmit="return checkPassword();">
Author by
Poppy
Passionate about programming. Good at java, jquery and little bit of .net. Working as a developer in MNC
Updated on June 04, 2022Comments
-
Poppy almost 2 years
How to use relative path in form action
<form action="/myapp/alterPassword" id="changepassword" method="post" autocomplete="off" onsubmit="return checkPassword();"> <div style="display: block; position: absolute; top: 15%; left: 35%; width: 480px;">
In the above code is there any way to use relative path instead of the myapp/alterPassword ?
-
Chen Ni almost 4 yearsThank you so much! After trying out a lot of different things this finally worked for me.