Step 1: Create a New serverlet to get the image stream. The Code is as follows:
Public class imageservlet extends httpservlet {
Public imageservlet (){
Super ();
}
Public void destroy (){
Super. Destroy (); // just puts "Destroy" string in log
// Put your code here
}
Public void doget (httpservletrequest request, httpservletresponse response)
Throws servletexception, ioexception {
Dopost (request, response );
}
Public void dopost (httpservletrequest request, httpservletresponse response)
Throws servletexception, ioexception {
Response. setcontenttype ("text/html ");
// Printwriter out = response. getwriter ();
Videoservice service = new videoservice ();
String id = request. getparameter ("ID ");
Byte [] imagedata = service. getimagedatabyid (ID );
If (imagedata! = NULL)
{
Response. setcontenttype ("image/PNG ");
Outputstream stream = response. getoutputstream ();
Stream. Write (imagedata );
Stream. Flush ();
Stream. Close ();
}
Else
{
Response. setcontenttype ("text ");
Response. getwriter (). Write ("attribute byarr not found ");
}
}
Public void Init () throws servletexception {
// Put your code here
}
}
Step 2: the JSP code is as follows:
<HTML>
<Head>
</Head>
<Body>
<%
Videoservice service = new videoservice ();
Arraylist <videobean> datalst = service. getvidelistinfobytype ("100", "1", "5 ");
If (datalst = NULL ){
System. Out. println ("datalst is null ...");
} Else {
For (INT I = 0; I <datalst. Size (); I ++ ){
%>
<% = Datalst. Get (I). getname () %> <br/>
"> <br/>
<%
System. Out. println ("name:" + datalst. Get (I). getname ());
}
}
%>
</Body>
</Html>