Let's say you have something like this:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<table>
<c:forEach items="${products}" var="product">
<tr>
<td>${product.name}</td>
<td>${product.description}</td>
</tr>
</c:forEach>
</table>
How can I see what other keys (like the keys: name or description) that this "product" object has? I'm mostly a JavaScript engineer, so JSP is still new to me.
Let's say for instance I wanted the price in a new <td>, but product.price doesn't work and I can't figure out the right key to access it's true name.
Tried searching for an answer online but not seeing it.
Something like this is a fragment of JSP code using JSTL tags. JSTL uses havily EL expressions in their tags. It is
<c:forEach>tag from your code. Even if a whole JSP page is defined, you might not know the attributes used there. If you try to access such pages in the browser then it fails with empty content or returns 404 error code. The last case is identified if your JSP pages underWEB-INFfolder.For what reason you can't still access the JSP pages in the view directory?
The fact is that
WEB-INFis a protected directory on the server; access to files from the outside is impossible. The application can store its files in this directory to ensure that they are not accessible to users. This primarily applies to configuration files and other internal files. JSP files in some MVC frameworks began to be placed there in order to limit direct access to the View, bypassing the controller. The same thing applies to servlets that implement the MVC pattern using a dispatcher. Since these JSPs cannot run without initialization on the controller, directly accessing such pages will throw exceptions.Initializing JSP pages performed by a controller where all attributes are prepared and put into a JSP scope. Once it prepared for showing, the controller uses a dispatcher to forward its request to the JSP page. All attributes are transfered to the new request and can be found by EL expressions in JSTL tags. So, you should look into controller code to find objects it passing to the JSP as an attribute. Generally a controller doesn't care about object structure because it saved them as
Object. EL expressions use an introspection mechanizms to look into the object and figure out its properties.