my dog learned polymorphism*
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 Murach's Java Servlets and JSP this week in the Servlets 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!
 
 
subject: Retrieve image from database and display it in jsp using multipart property
 
Similar Threads
Apache FileUpload
populating @OneToOne from query
need help?
column heading dates ...
connection failure exception