In a Struts Action, I want to get a parameter from the URL or from a hidden field, when the parameter in the URL is not set.
To retrieve the parameter from the URL is as follows:
String userId = request.getParameter("userId");
But the problem is now, the HTML is based on forms (legacy code). And I observerd that the parameter userId may be reset to null. Is it an option to set the parameter in a form in a hidden field as well? Would I need to define a parameter in the dynaForm for this? How would I retrieve the parameter from the hidden field?
The parameters in hidden fields are set as any other field, also they can be retrieve the same way.
To check if it is null you just:
http://commons.apache.org/lang/apidocs/org/apache/commons/lang/StringUtils.html#isNotBlank(java.lang.String)
*Edit adding more info
request.getParameter doesn’t distinguish between get nor post variables, so if you have a parameter from the URL you can get it with the same method.