I have a form which has 30 different fields. As passing them all to the controller need to have an attribute for each along with a pair of getter, setters.
I am going to make the form fields as an object and send the object to the controller.
I am using the following code *but some people suggest its a bad practice to call a java method from jsp and use JSTL instead, but do not know how to implement it using JSTL. Is there any other method to do it?*
My JSP
<s:form>
code to implement form goes here
</s:form>
<jsp:useBean id="obj" class="com.User"/>
<jsp:setProperty property="*" name="obj"/>
<%
String myoutput = myController.Xclass(obj);
out.print(myoutput);
if(myController.Xclass(obj).equals("output"))
{
out.print("The form is successfully submitted.");
}
%>
The controller
public String Xclass(User obj){
return "output";
}
To clarify my class diagram is a following:
User Class {
all the attributes and getters setters
}
myController class extends User {
public String XClass(User obj){
... work on the inputes ...
return "output";
}
}