Reputation: 267077
In my jsp, I have the following:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set scope="request" var="test" value="${com.xxx.foo.Bar.getBar()}" />
But this seems to store test
as a string with the literal value of ${com.xxx.foo.Bar.getBar()}
rather than the return value of that method (which is an enum).
Here getBar()
is an instance method, not a static method.
What am I doing wrong?
Upvotes: 0
Views: 365
Reputation: 267077
As suggested by others in the comments, I solved this by creating a servlet and passing in the info to the jsp, like this:
public class FooServlet extends HttpServlet
{
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
Bar bar = new Bar();
request.setAttribute("bar", bar.getFooBar() );
request.getRequestDispatcher("/myPage.jsp").forward(request, response);
}
}
In the jsp:
<%=request.getAttribute("bar") %>
Upvotes: 0