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

How can I resize an image from database table and show it

 
Shounak Kundu
Ranch Hand
Posts: 60
IBM DB2 Eclipse IDE Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am trying to select an image from the table and change it to a thumbnail. On clicking the thumbnail, the original sized image will appear.

How can I do that ? Here's my code.


You can see, I have tried to use BufferedImage, but could not. Can you help me ?
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, first of all you'll want to get that code out of a JSP and into a servlet where it belongs. By putting it in a JSP you are mixing the output of your Java code with the output of the JSP -- all that HTML code. That's guaranteed to produce garbage instead of an image.
 
Shounak Kundu
Ranch Hand
Posts: 60
IBM DB2 Eclipse IDE Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually , I am getting the images properly.
Now, I am trying to convert it first to a thumbnail, and then on clicking the thumbnail it'll show the original image.

How can I do that ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You use <img> tags to show images. The src of the tags reference servlets that serve the image data.
 
Shounak Kundu
Ranch Hand
Posts: 60
IBM DB2 Eclipse IDE Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bang on target dude. This part of code produces the image :


How can I put this within an <img src=""> ? Because , I have tried this , just to end up showing an error ....


But it is showing error , when I am giving the scriplet tag ...

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In HTML do put the image data into the HTML page? Of course not. Why are you trying to do that with a JSP, which just creates an HTML page to send to the client?

The image data is useless in the JSP. The JSP will use the <img> tag, as I have already said, whose src attribute is the URL of a servlet that supplies the image response.
 
Shounak Kundu
Ranch Hand
Posts: 60
IBM DB2 Eclipse IDE Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. So, are you trying to say to do something like this :

Create a jsp page. In that page, create an <img> tag, something like this:




And in the servlet :



Are you sure , this is gonna work ? Because , the image will not be scaled down , right ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the image needs processing, it can be done in the servlet.
 
Shounak Kundu
Ranch Hand
Posts: 60
IBM DB2 Eclipse IDE Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault said,

If the image needs processing, it can be done in the servlet.





How can I process an image that I get from database ?


I am new to all these , please guide me.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is nothing in the JSP or servlet realm for this. Look into JAI or other Java APIs for image manipulation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic