how to show blob(graphics)data from paradox by jsp

my paradox table have blob data type(graphics),how can i make it be shown in browser by jsp? (jdbc used)
ws1999Asked:
Who is Participating?
 
yongsingConnect With a Mentor Commented:
You specify the URL of the JSP, and pass any parameter to it. For example, let's say the name of the JSP file is ShowImage.jsp:

<IMG src="http://localhost/jsp/ShowImage.jsp?id=1234">

For this example, a paramter 'id' is passed to the JSP. The JSP will query the database based on the parameter value.
0
 
yongsingCommented:
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>

<%
try {
    // connect to database
    Connection  connection = DriverManager.getConnection(url, userID, password);

    Statement statement = connection.createStatement();

    // retrieve image
    ResultSet resultSet = statement.executeQuery("select image from mytable where id='123'");
    if (resultSet.next()) {
        response.setContentType("image/jpg");
        BufferedInputStream inputStream = new BufferedInputStream(resultSet.getBinaryStream(1));
        OutputStream outputStream = new BufferedOutputStream(response.getOutputStream(), 1024);
        int b;
        while ((b = inputStream.read()) != -1) {
            outputStream.write(b);
        }
        inputStream.close();
        outputStream.close();
     }
    statement.close();
    connection.close();
} catch (Exception e) {}
%>
0
 
rjackmanCommented:
hi
i want to add few to  yongsing's comment
Jsp's are mostly used for dynamic displays though u can have the java code in them
i feel u should write a bean which will do the backend job and just returns the datat needed by jsp to display
cheers
RJ
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
ws1999Author Commented:
hi,yongsing,

The code i have added to my program,but there is no image showed in my browser.why

ws1999
0
 
yongsingCommented:
You need to put the image in a IMG tag:

<IMG src="url">

where url is the URL to the JSP file or servlet.
0
 
ws1999Author Commented:
hi,yongsing

but the blobimage is retrieved from database,how can i specify the url
0
 
ws1999Author Commented:
hi,yongsing,

yes, i think your suggestion will work,but another problem is when run Jsp file, there is a column not found exception,but I'm sure the column exists,and in Jbuilder's JDBC explorer I also cannot found the column which contains the Blob(graphics data type in a paradox table),I wonder where is the column?

Thanks

ws1999
0
 
yongsingCommented:
Are you sure that you got the name of the column correct?
0
 
ws1999Author Commented:
yes,no problem of the name, but still it cannot be found
0
 
yongsingCommented:
Use Connection.getMetaData() to get the names of the table's columns.
0
 
ws1999Author Commented:
hi,yongsing,

The problem is why the jdbc explorer of Jbuilder also can not show this blob graphics, it seems it can not explain this kind of datatype,may be i need to install some driver to support it.
0
 
yongsingCommented:
Which line of your code does the problem occur? What exception is thrown? Does the column exist?
0
 
amp072397Commented:
ws1999:

You have many open questions to which you must return:

http://www.experts-exchange.com/jsp/qShow.jsp?ta=msaccess&qid=20264790
http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20256743
http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20250343
http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20249986
http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20187323
http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20184015
http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20181707
http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20180448
http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20169990
http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=11401958
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20230693
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20194172
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20187856
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20187852
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20187466
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20182301
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20182182
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20181487
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20181301
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20180787
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20180436
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20172201
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20153303

To assist you in your cleanup, I'm providing the following guidelines:

1.  Stay active in your questions and provide feedback whenever possible. Likewise, when feedback has not been provided by the experts, commenting again makes them receive an email notification, and they may provide you with further information. Experts have no other method of searching for questions in which they have commented, except manually.

2.  Award points by hitting the Accept Comment As Answer button located above and to the left of that expert's comment.

3.  When grading, be sure to read:
http://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp#3
to ensure that you understand the grading system here at EE. If you grade less than an A, you must explain why.

4.  Questions that were not helpful to you should be PAQ'd (stored in the database for their valuable content?even if not valuable to you) or deleted. To PAQ or delete a question, you must first post your intent in that question to make the experts aware. Then, if no experts object after three full days, you can post a zero-point question at community support to request deletion or PAQ. Please include the link(s) to the question(s).
CS:  http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
At that point, a moderator can refund your points and PAQ or delete the question for you. The delete button does not work.

5.  If you fail to respond to this cleanup request, I must report you to the Community Support Administrator for further action.

Our intent is to get the questions cleaned up, and not to embarrass or shame anyone. If you have any questions or need further assistance at all, feel free to ask me in this question or post a zero-point question at CS. We are very happy to help you in this task!


thanks!
amp
community support moderator

2/8
0
 
ws1999Author Commented:
i have accpeted all these answer, why always send me mail for this?????

0
 
ws1999Author Commented:
i have accpeted all these answer, why always send me mail for this?????

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.