Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to store an image from a jsp page to Database

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to store an image from a jsp page . I will be using setBinaryStream method from PreparedStatement ?


But how can I pass the data from jsp to the servlet ??

Any ideas or suggestions please specify.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

But how can I pass the data from jsp to the servlet ??

Not sure what the issue is with this- both Servlet and JSP are running on the server JVM so just pass the image as you would any other object.

Or are you asking how you upload the binary data from the client machine to the Servlet?
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks paul for responding ,

The question is i have a User Object , in which he has Name , Age , Image


how can i send the image
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its up to you, but a byte array sounds like a good candidate.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks paul ,

do i need to include byte array data type as setter and getter methods with User Object directly ??Please specify.
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

That is good way if you declare your image type to byte array like

byte[] image;

And good to make getter and setter method in User object so you cane get user.getImage() method.

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You Nishan .

I asked this particular question to include byte array[] inside the DTO because.

in a site i read this should not be a part of DTO.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic