I have two files which is Form.jsp and Util.jsp
What I want to do is I want to substitute the <%=sType%>
attribute with a function call name checkParam
and pass the parameter
Form.jsp
sType is a variable
sType=request.getParameter("type")!=nullrequest.getParameter("type").toString():"";
<form name="myFrm" method=post action="frmAction.jsp?type=<%=checkParam(sType)%>">
Util.jsp
public String checkParam(String mParam)
{
//mycode
}
<%=sType%>"> is jsp code, right? then why is it in a .html file? JSP files are rendered by the server and since can process java code, hence the name Java Server Pages. HTML files are served as resources and no such rendering is done on server side. If you want the form to be configured dynamically use either a .JSP file to reside the form or use an ajax call and javascript/jquery to set the action parameter manually.
Even if you used a .JSP to render the form i think the code should be written with a place holder.
<form name="myFrm" method=post action="frmAction.jsp?type=${sType}">
If you are using JSP use standard tag libraries. Coding like <%=sType%> is bad practice, as of my understanding.
According to the edit I think the statement should be
sType=(request.getParameter("type")!=null) ? request.getParameter("type").toString():"";
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments