It's not a secret anymore!*
The moose likes Spring and the fly likes Retrieve image from database and display it in jsp using multipart property Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Retrieve image from database and display it in jsp using multipart property" Watch "Retrieve image from database and display it in jsp using multipart property" New topic
Author

Retrieve image from database and display it in jsp using multipart property

monicka rk akilan
Greenhorn

Joined: Jan 04, 2013
Posts: 8
Hello all,

I am trying to save and retrieve from database.
Saving is working perfectly . but when i try to retrive
its showing error in the place of casting ByteArrayInputStream to multipart


if ((fileList.get(0).getFileType()).equals("abc")) {
commonVo.gettInfoVO().setStPhoto(

=================================================================
(MultipartFile) fileList.get(0).getInputStream());
here i got error as

SEVERE: Servlet.service() for servlet Havila threw exception
java.lang.ClassCastException: java.io.ByteArrayInputStream cannot be cast to org.springframework.web.multipart.MultipartFile
=================================================================

}


help me to resolve this problem.

Volodymyr Levytskyi
Ranch Hand

Joined: Mar 29, 2012
Posts: 505
    
    1

Hello!

ClassCastException means that you try to assign to variable wrong type. Type of variable does not have type of object you assign to it.
Simply change variable type to type of what you assign to it.
This causes exception

Check if MultipartPartFile extend InputStream .


True person is moral, false is right!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Retrieve image from database and display it in jsp using multipart property