Reputation: 1330
I need to grab a dynamically-named variable off of the request. This works in scriptlet form, but I'd rather not clutter up the page with scriptlets.
<%
String requestValueKey = "something_" + request.getParameter("State") + "_" + request.getParameter("UUID");
String requestValue = request.getParameter(requestValueKey);
%>
I'd like to switch it to JSTL but I can't figure out how to come up with a dynamically named session value key that relies on other values in the session.
Upvotes: 2
Views: 1229
Reputation: 1108802
Use <c:set>
to prepare the dynamic key and use brace notation []
to get a value by a dynamic key.
<c:set var="requestValueKey" value="something_${param.State}_${param.UUID}" />
Then you can get it by ${param[requestValueKey]}
in remnant of the page.
Upvotes: 2