Search code examples
jspspring-mvcjsp-tags

can't get request parameter with core taglib, works with request.getparameter?


EDIT: found it at last. It doesn't work in Jetty for some reason, but worked in Tomcat when i built and ran there. No idea why though...

Oh, man i went crazy last night trying to sort this out...

simple premise:

using a Spring requestdispatcher and controller class, simple jsp page as view.

in my controller:

request.setAttribute("banana", "myValue");

if use the reqular jsp code:

<%=request.getAttribute("banana")%>

it prints as expected

but i CANT get it to work using c-taglib. I've tried everything:

<c:out value="${param.banana}"/> <c:out value="${requestScope.banana}"/> and like 4 more.

Nothing works... it just prints the value as-is i.e. ${param.banana} as text.

I have looked around but couldn't find any solution, i must be an idiot. Please help me out.

EDIT forgot to clarify: i have included the appropriate jspheader

<%@ taglib prefix='c' uri='http://java.sun.com/jstl/core_rt' %>

also tried

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

Solution

  • For others reference:

    This was an issue with the Jetty server i ran on. When deploying on Tomcat, everything worked as expected.

    I'm not exactly sure what it was, i ran it as-is from within Intellj, but guess it had something to do with what libraries were deployed with the Jetty on start-up.