Solved

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

Posted on 2001-07-18
15
1,009 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
Comment Utility
<%@ 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 9

Expert Comment

by:yongsing
Comment Utility
Are you sure that you got the name of the column correct?
0
 

Author Comment

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

Expert Comment

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

Author Comment

by:ws1999
Comment Utility
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
Comment Utility
Which line of your code does the problem occur? What exception is thrown? Does the column exist?
0
 

Expert Comment

by:amp072397
Comment Utility
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
Comment Utility
i have accpeted all these answer, why always send me mail for this?????

0
 

Author Comment

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

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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)
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

771 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

10 Experts available now in Live!

Get 1:1 Help Now