Solved

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

Posted on 2001-07-18
15
1,053 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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
 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

707 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