I have a jsp page which iterates a list of users. Each user has his own display picture. I want to display these display pictures.
The problem is that when the page is loaded all the images are the same instead of a different image for each user.
The image tag in the iterator is this :
<img src="<s:url action="getUserImage">
<s:param name="user">
<s:property value="userId"/>
</s:param>
</s:url>"/>
and the action looks like this
this.inputStream = ByteArrayInputStream(userService.getUserById(Integer.parseInt(user)).getDisplayPicture());
While debugging I discovered that when executing the action for each image, the ‘user’ property is always the same.
The funny thing is that when I inspect the imgs elemnt on a browser, the src parameters are all correct (meaning each of them has its own different values).
I’m using spring framework, auto wiring action classes ..
struts.objectFactory value =”spring”
@Component
@Scope(“prototype”)
did the trick !
action class was reusing the same id for each request