Arthur Wang
asked on
how to make dynamic form url in JSP
I have a legacy system developed 10 years ago.
A jsp page---SalesEditBillingAdd ress.jsp
second jsp page---marketingEditBillin gAddress.j sp
The reason to pass the parameter is because the generic page----edit_billing_addre ss.jsp has different form action need to be submitted based on different parameters.
however, tomcat 8.0 with java 1.8 complain about this line of code:
javax.servlet.ServletExcep tion: javax.servlet.jsp.JspExcep tion: Cannot retrieve mapping for action /actions/${param.dept}/edi tBillingAd dress
The example on this page:
http://beginnersbook.com/2013/12/jsp-include-with-parameter-example/
shows that my code is nothing wrong about it.
my question is: how to make the parameter work in the action URL?
I also tried the following code:
but it doesn't work because the eclipse compiler give error message due to only one closed form tag could be found.
A jsp page---SalesEditBillingAdd
<jsp:include page="/WEB-INF/forms/include/edit_billing_address.jsp" >
<jsp:param name="dept" value="sales"/>
</jsp:include>
second jsp page---marketingEditBillin
<jsp:include page="/WEB-INF/forms/include/edit_billing_address.jsp" >
<jsp:param name="dept" value="marketing"/>
</jsp:include>
The reason to pass the parameter is because the generic page----edit_billing_addre
<html:form action="/actions/${param.dept}/editBillingAddress">
<html:text name="customerBillingAddressBean" property="address1" maxlength="60"> </html:text>
.............
<html:text name="customerBillingAddressBean" property="contact" maxlength="60"></html:text>
<html:text name="customerBillingAddressBean" property="email" maxlength="80"></html:text>
<button type = "submit" class ="btn btn-primary">Submit</button>
</html:form>
however, tomcat 8.0 with java 1.8 complain about this line of code:
<html:form action="/actions/${param.dept}/editBillingAddress">
javax.servlet.ServletExcep
The example on this page:
http://beginnersbook.com/2013/12/jsp-include-with-parameter-example/
shows that my code is nothing wrong about it.
my question is: how to make the parameter work in the action URL?
I also tried the following code:
<c:set var="myVar" value="${param.dept}" />
<c:if test = "${myVar eq 'sales'}">
<html:form action="/actions/sales/editBillingAddress">
</c:if>
<c:if test = "${myVar eq 'marketing'}">
<html:form action="/actions/marketing/editBillingAddress">
</c:if>
............. many input fields ...............
<button type = "submit" class ="btn btn-primary">Submit</button>
</html:form>
but it doesn't work because the eclipse compiler give error message due to only one closed form tag could be found.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
My jstl jar file placed in the lib folder of the project is: jstl-1.2.jar, but my old working code:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
not working any more, instead I have to change every web page to use the following line:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
and my web.xml file is like this:
Open in new window
Based on this page:
https://stackoverflow.com/questions/31355583/difference-between-http-java-sun-com-jsp-jstl-core-and-http-java-sun-com-jst
I have to change the facet, but from Project-->Properties --> project facets, it shows Dynamic web Module 2.3, I am trying to change it, but Eclipse does NOT allow me to change it.
what is wrong with my project setting? I am thinking if I could go back to jstl 1.2 instead of the deprecated 1.0, my original problem/question might be solved.
Screen-Shot-2017-06-09-at-12.01.43-A.png