Very often, you write OFBiz Events so as to have complete control over HTTP/HTTPS request parameters. Getting those parameters out of the HttpServletRequest
object and into your program is simplified when using OFBiz tools.
The following code snippet demonstrates taking HttpServletRequest
object request parameters from the request and placing them in local variables for processing:
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilValidate public static String myEvent(HttpServletRequest request, HttpServletResponse response) { // Some code up here Map httpParams = UtilHttp.getParameterMap(request); // use the OFBiz utility to make this easy String param1 = (String) httpParams.get("param1"); // Some Validation Examples follow if(UtilValidate.isEmpty((String) httpParams.get("param2")) { return "error"; } if(UtilValidate...