In a query like the one below there are various fields where the names are
the same, yet they originate from different tables:
<sql:query var="Amenities">
SELECT rn.resort_id, oa.all_inclusive, oa.beach, oa.casino,
oa.child_care, oa.cross_country_skiing, oa.fishing, oa.game_room,
oa.grocery_store, oa.hairdresser, oa.health_club, oa.horseback_riding,
oa.housekeeping, oa.lake, oa.laundry, oa.raquetball, oa.scuba,
oa.ski_school, oa.tennis, oa.whirlpool_hottub, oa.boating, oa.shopping,
oa.auto_rental, oa.golf, oa.sauna, oa.restaurant, na.golf, na.auto_rental,
na.restaurant, na.scuba, na.water_skiing, na.cross_country_skiing,
na.boating, na.ski_school, na.medical_facility, na.beach, na.casino,
na.grocery_store, na.health_club, na.horseback_riding, na.fishing,
na.attractions, na.kareoke, na.wind_surfing, na.shopping, na.lake
FROM resort_name rn
LEFT JOIN nearby_amenities na ON rn.resort_id = na.resort_id
LEFT JOIN onsite_amenities oa ON rn.resort_id = oa.resort_id
WHERE rn.resort_id = ?
<sql:param value="${resortID}"/>
</sql:query>
In jsp I would normally compare the value of the field from a specific table
like so (after putting it into a resultSet and iterating over the data):
<% variable = rs.getString("oa.golf");
if (variable.equals("T")) { %><td><li>Golf</li></td><% } %>
Using JSTL it seems as though I'm no longer able to specify the field from
the table I desire. After running my query and iterating over the data in a
forEach, I seem to only be able to specify the field name and not the table
abbreviation with it.
<c:forEach items="${Amenities.rows}" var="amenitiesRow">
<c:if test="${amenitiesRow.golf == 'T'}"><td><li>Golf</li></td></c:if>
</c:forEach>
When I attempt replacing "amenitiesRow.golf" with "amenitiesRow.oa.golf" it
does not appear to recognize the data (I don't get any errors). If anyone
knows of a way I can call the field as "oa.golf" or "na.golf" (specifiying
the table the field is from) using JSTL, it would be greatly appreciated.
John Engilis