简体   繁体   中英

Grabbing arraylist of objects from servlet

I have an arraylist of objects in my servlet where I want to call it in my jsp file. I'm not sure how to go about doing this.

inside my servlet I have:

public ArrayList <Song> searchedSongs = new ArrayList <Song> ();

where the object is a Song.java file. Inside my jsp file I have:

<strong style="color: #ff9642;">CART:</strong><br/>    
<% ArrayList<Song> results = (ArrayList<Song>) session.getAttribute("results"); %>
<% out.print(results.size()); %> items

I am getting an error saying my Song cannot be resolved

You should import the class in you JSP

<%@ page import="com.entity.Song" %>

You might refer to here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM