Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Value in Jsp using UseBean

Friends I am sending My List from Action class, here is the code

//Code of my Action class

List matchUsersInTracker = new ArrayList<User>();

DynamicQuery userTrackerquery = DynamicQueryFactoryUtil.forClass(User.class, PortalClassLoaderUtil.getClassLoader())
    .add(PropertyFactoryUtil.forName("userId").in(DynamicQueryFactoryUtil.forClass(UserTracker.class, PortalClassLoaderUtil.getClassLoader())
    .setProjection(ProjectionFactoryUtil.property("userId"))));

matchUsersInTracker = UserLocalServiceUtil.dynamicQuery(userTrackerquery);

//Pass this entire List of user 
if(matchUsersInTracker!=null)
{
    actionRequest.setAttribute("match_base_Users", matchUsersInTracker);
}

//code in My Jsp -------

Now in Jsp I am using useBean:

<jsp:useBean id="match_base_Users" class="java.util.ArrayList"  scope="request">
</jsp:useBean>

It gives me ClassCastException, now converting each and every element to user class one by one in for loop isn't the feasible way.

Increases loading time of my jsp.

So any guesses how can I send a User List from ActionClass to Jsp

I also referred this question but was not able to come out with a resolution.

I just want to display data in jsp

like image 622
Jay Trivedi Avatar asked Jun 15 '26 23:06

Jay Trivedi


1 Answers

You don't need <jsp:useBean> at all if you're already using a MVC framework which manages the beans in the desired scope. The <jsp:useBean> is only useful if you aren't using a MVC framework which managed the beans by itself.

Get rid of it and just access it by ${match_base_Users} directly.

like image 113
BalusC Avatar answered Jun 22 '26 15:06

BalusC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!