Escolar Documentos
Profissional Documentos
Cultura Documentos
Francois Degrelle's
Vous aimerez aussi…
J'aime ce blog
blog about some Oracle technologies
Rechercher ok
Information is not knowledge, Knowledge is not wisdom, Wisdom is not truth, Truth is not beauty, Beauty is not love, Love is not music, Music is THE
BEST!
-- Display image 31
The web page could be called with the following URL and did what I was asked to
do
This works like a charm but has a caveat that I discovered when presenting it to
the network department. The network department didn’t like the idea of exposing
the database server to the Internet, which indeed is considerably unsafe.
Back to the whiteboard, I thought of using Web Service. This approach just didn’t
feel right and appeared to be too complex for this little solution to build.
Eventually I decided to write a JavaServer Page to do the job.
The Java class to stream the image from the database column
package image;
import java.sql.*;
import java.io.*;
import java.util.*;
import oracle.jdbc.*;
import oracle.sql.*;
public class images
{
/*-------------------------
* Get the Blob image
*------------------------*/
public static byte[] getPhoto (OracleConnection conn, int iNumPhoto)
throws Exception, SQLException
{
String req = "" ;
Blob img ;
byte[] imgData = null ;
Statement stmt = conn.createStatement ();
// Query
req = "Select image From IMAGES Where ImageID = " + iNumPhoto ;
rset.close();
stmt.close();
return imgData ;
}
The JavaServer Page includes the bean so its methods can be accessed in the
JSP page using scriplets and “photo” as a named bean reference
int iNumPhoto ;
oracle.jdbc.driver.OracleConnection conn = null;
if ( request.getParameter("imgID") != null )
{
iNumPhoto = Integer.parseInt(request.getParameter("imgID")) ;
try
{
conn = …………;
conn.setAutoCommit (false);
To display the image on the web, I now use the following image URL
Special thank you to Frank Nimphius for its good suggestions on the style ;o)
Francois
Créer un blog gratuit sur over-blog.com - Contact - C.G.U. - Rémunération en droits d'auteur - Signaler un abus - Articles les plus commentés