Hi
I have a servlet which reads image data from a database and displays the image
on the clients browser.
Now in order for this to happen I am having to create the image as as file on my
server and then have a
url which refers to the image file on the server to display it. Is there any way
I do the same process but without creating an
actual file on the server (displaying the image dynamically). My code is as
follows:
try {
st = myConn.createStatement();
/*
** set the size of the data to bring back
*/
int maxsize = 5*1024*1024;
st.executeUpdate("set textsize " + maxsize);
rs = st.executeQuery(_sql);
if (rs == null) {
log("rs is null");
} else {
log("rs is not null");
}
log("rs " + rs);
int _rows = 0;
while (rs.next())
{
_rows++;
InputStream in = rs.getBinaryStream(1);
OutputStream out = new FileOutputStream
("C:\displayaimages\myimage.jpg");
byte[] buffer = new byte[4096];
int len;
while ((len = in.read(buffer)) > 0 )
{
out.write(buffer, 0, len);
}
out.close();
log("Image displayed");
}
/*
** Create a html form dynamically with all the parameters which will post to the
change.stm page
*/
String page = "<html><head><link type=\"text/css\" href=\"style/wlbp_main.css\"
rel=stylesheet><title>" + _desc
+ "</title></Head><body>" + _desc ;
if (_rows > 0) {
page += "<img id=pic
src='http://140.108.35.198/EmployeeImages/" + _file + "'";
} else {
page += "<h2> No Imaged Retrieved </h2>";
}
resp.setContentType("text/html");
PrintWriter out2 = new PrintWriter(resp.getOutputStream());
page += "></body></html>";
out2.println(page);
out2.close();
GetConnectionCache.releaseConnection(myConn,_jagCache);
log("Cache released ");
}
thanks in advance
Diese Nachricht ist vertraulich. Sie ist ausschliesslich fuer
den im Adressfeld ausgewiesenen Adressaten bestimmt.
Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten
wir um eine kurze Nachricht. Jede unbefugte Weiterleitung
oder Fertigung einer Kopie ist unzulaessig. Da wir nicht die
Echtheit oder Vollstaendigkeit der in dieser Nachricht
enthaltenen Informationen garantieren koennen, schliessen wir
die rechtliche Verbindlichkeit der vorstehenden Erklaerungen
und Aeusserungen aus. Wir verweisen in diesem Zusammenhang
auch auf die fuer die Bank geltenden Regelungen ueber die
Verbindlichkeit von Willenserklaerungen mit verpflichtendem
Inhalt, die in den bankueblichen Unterschriftenverzeichnissen
bekannt gemacht werden.
This message is confidential and may be privileged. It is
intended solely for the named addressee. If you are not the
intended recipient please inform us. Any unauthorised
dissemination, distribution or copying hereof is prohibited.
As we cannot guarantee the genuineness or completeness of
the information contained in this message, the statements
set forth above are not legally binding. In connection
therewith, we also refer to the governing regulations of
WestLB concerning signatory authority published in the
standard bank signature lists with regard to the legally
binding effect of statements made with the intent to
obligate WestLB.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html