Java – jsp:param with Java class

By | October 22, 2023

I have a JSP file that includes another JSP file. The first JSP should pass an instance of a Java class (widget) to the second JSP file.

This is what I have:

The first JSP:

<jsp:include page="/container/SpecialWidget.jsp">
     <jsp:param name="widget" value="${widget}"/> // widget is a .Java POJO

The second JSP:


The problem is that this code gives an error (it says it doesn’t know ID). If I omit the “.id” part, the page prints the Java code for the Java class, which means the class has been transferred correctly. If I change the ${widget} rule of the first page in, for example, ${} and I try to print ${param.widget}, everything works fine.

My question: Why can’t I pass a Java class and directly call upon its attributes? What am I doing wrong?

Edit: error message: Caused by: javax.el.PropertyNotFoundException: Property ‘id’ not found on type java.lang.String

Best Solution

I managed to fix my problem with the following code:

<c:set var="widget" value="${widget}" scope="request" />
<jsp:include page="/SOMEWHERE/SpecialWidget.jsp"/>

Thank you both for your help:) It saved my day

Category: Uncategorized