Retrieve multiple objects with MVC/FrontController for view in JSP.
I have made a MVC system (front-end only); a link call the url: ?page=createSomething to the FrontController, that is implemented as a Servlet, and then dispatch to createSomething.jsp. That抯 all fine, but I need to retrieve 2-3 list to use in dropdowns, and that抯 here I give up!
A simple scenario is to retrieve a single object eg a member: I call the url: ?page=viewmemeber&command=viewMemeber&id=5. The Servlet call a commandHandler witch return a member, use setAttribute(搈ember? member); and then dispatch to viewmember.jsp and use JSTL to view the member. That抯 all fine, as long I only need to set a single object or a list of objects.
The problem is now I want to create a member and need to retrieve 2-3 list to use in a dropdown when creating a member.. I can do a ?page=createmember&command=getAllCountries, but that will only allow a dropdown of countries.
Is the solution to use a command pattern and use: ?page=createmember&command=getAllCountrysAndCitysAnd?
My servlet
...
commandhandlerclass = Class.forName("controllers.CommandHandler");
commandhandlerobject = commandhandlerclass.newInstance();
Object arguments[] =new Object[]{ requestContextMap};
commandhandlermethod = commandhandlerclass.getMethod(
getString(requestContextMap,"command"),
new Class[]{ requestContextMap.getClass()}
);
commandhandlerreturndata = commandhandlermethod.invoke(commandhandlerobject, arguments);
...
request.setAttribute("bean", commandhandlerreturndata);

