Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Upload image to server

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
     Greetings to all!

     JSP code:


in Servlete-code



    IO-code in ImageService-class


  As a resulte:
1. In log:
- stream to servlet without problem
- Buffer is not null
- Temporary is not null
- request is not null
- fileOutputStream is not null

2. In "newimage"-directory new file is creating. For example: "Picture147".
  But this file IS EMPTY....

  So, html/js send  a file on server,  servlet receives it with request ("stream to servlet without problem"), ImageService serialize it and creates a new file.
  But serialized data is not saved in this new file!

  Additionally:  size of image-file, wich i try to save from web-page to server has a size: 250 × 188

   




 
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you way easier using a multipartfile to pass your file to your controller
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!