Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
| Search | Today's Posts | Mark Forums Read
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 2nd, 2008, 11:44 PM
Registered User
Join Date: Nov 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to display pictures on JSP page?

HI all. pls help me. I already upload image into blob field Oracle. Now I want to display picture on JSP page from oracle db blob field.
1. how i select pic from blob
2. how to display pic on jsp
 how I decide this problem?

  #2 (permalink)  
Old November 3rd, 2008, 09:02 PM
Friend of Wrox
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts

It doesn't matter whether the page you display the picture in is a JSP page or ordinary HTML page.

The "trick" is to simply use an HTML image control but to specify a JSP-based URL.

That is, something like:
    <img src="http://www.yoursite.com/getImageFromDB.jsp?id=778" />
There are MANY possible variations on the form of the URL. You might use URL rewrites, for example, to have a "pretty" looking url such as:
    <img src="http://www.yoursite.com/image/778" />
where in actuality, behind the scenes, that is transformed into the first URL I showed.

So then what you have to do is to write JSP code to retrieve the BLOB from the DB and send it as a binary stream to the browser. And there are many ways to do that. I think you could google for solutions a lot faster than I could write one for you. You shouldn't need more than about 20 or 30 lines of code to do this, by the way.

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to display pictures on JSP page? coitri JSP Basics 19 November 24th, 2008 06:22 AM
JSP page not display data coming from socket ashvinm JSP Basics 0 February 20th, 2008 02:10 AM
Display many pictures NBM Java GUI 0 September 3rd, 2006 06:54 AM
How to display Vietnamese Unicode on JSP page? minhpx JSP Basics 4 May 18th, 2006 11:16 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.