• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Ranch Hand
Posts: 514
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 .
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic