Inside a POST in a .jsp file, I’d like to do something like this:
<input type="text" name="...">
And inside the servlet I’d like to do:
request.getParameter(...)
Now where should and how should I declare “…” so that I can avoid duplication and reuse the same String.
Should this go in an interface like this:
public interface SO {
String POST_PARAM = "userinput";
}
Or in a property file? Or …?
In any case, how do I then access this from the .jsp and from the .java file?
You can define constants like
final String POST_PARAM = "userinput";and then use them in markup:<input type="text" name="<%=POST_PARAM%>">.Moving fields names to properties file does not sound as a beneficial unless you have reasons to do this.
To get parameter value from HTTP request caused by form submit say
request.getParameter(POST_PARAM).I hope this helps.