Solved

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

Posted on 2001-07-18
15
1,022 Views
Last Modified: 2012-05-04
my paradox table have blob data type(graphics),how can i make it be shown in browser by jsp? (jdbc used)
0
Comment
Question by:ws1999
15 Comments
 
LVL 9

Expert Comment

by:yongsing
ID: 6297054
<%@ 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
 
LVL 3

Expert Comment

by:rjackman
ID: 6297293
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
 

Author Comment

by:ws1999
ID: 6304638
hi,yongsing,

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

ws1999
0
 
LVL 9

Expert Comment

by:yongsing
ID: 6307098
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
 

Author Comment

by:ws1999
ID: 6308161
hi,yongsing

but the blobimage is retrieved from database,how can i specify the url
0
 
LVL 9

Accepted Solution

by:
yongsing earned 100 total points
ID: 6308369
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
 

Author Comment

by:ws1999
ID: 6312141
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 9

Expert Comment

by:yongsing
ID: 6315682
Are you sure that you got the name of the column correct?
0
 

Author Comment

by:ws1999
ID: 6315751
yes,no problem of the name, but still it cannot be found
0
 
LVL 9

Expert Comment

by:yongsing
ID: 6316292
Use Connection.getMetaData() to get the names of the table's columns.
0
 

Author Comment

by:ws1999
ID: 6320780
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
 
LVL 9

Expert Comment

by:yongsing
ID: 6320851
Which line of your code does the problem occur? What exception is thrown? Does the column exist?
0
 

Expert Comment

by:amp072397
ID: 6789137
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
 

Author Comment

by:ws1999
ID: 6865092
i have accpeted all these answer, why always send me mail for this?????

0
 

Author Comment

by:ws1999
ID: 6865094
i have accpeted all these answer, why always send me mail for this?????

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
java  and programming certification ? 4 86
Image decoding from Camera 3 72
Spring Framework HTTPSession management 1 24
even odd program using while loop 3 29
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now