| Author |
How can I resize an image from database table and show it
|
Shounak Kundu
Ranch Hand
Joined: Jul 29, 2010
Posts: 60
|
|
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 ?
|
Shounak
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16482
|
|
|
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
Joined: Jul 29, 2010
Posts: 60
|
|
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
Joined: Jan 10, 2002
Posts: 56168
|
|
|
You use <img> tags to show images. The src of the tags reference servlets that serve the image data.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Shounak Kundu
Ranch Hand
Joined: Jul 29, 2010
Posts: 60
|
|
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
Joined: Jan 10, 2002
Posts: 56168
|
|
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
Joined: Jul 29, 2010
Posts: 60
|
|
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
Joined: Jan 10, 2002
Posts: 56168
|
|
|
If the image needs processing, it can be done in the servlet.
|
 |
Shounak Kundu
Ranch Hand
Joined: Jul 29, 2010
Posts: 60
|
|
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
Joined: Jan 10, 2002
Posts: 56168
|
|
|
There is nothing in the JSP or servlet realm for this. Look into JAI or other Java APIs for image manipulation.
|
 |
 |
|
|
subject: How can I resize an image from database table and show it
|
|
|