Marcel ...
About your article "Display a blob in RichUI" ...
I need to work with BLOB in RUI. After research I came to the same conclusion. BLOB is not supported in RUI .. Well, you solved this with the Java Servlet ..
I will expose my situation to see if colleagues guide me the best way ..
In my case .. I am writing the images (photos) to database (DB2), with column of type BLOB. So far so good.
To recover them, in egl-service, also okay ..
Now what I need is, get this BLOB and throw it to RUI .. and I've been thinking to do the same as you ..
But how ??
I saw that you access the database in your Servlet ... (which I do not like) ..
What I would need would be to send the Blob to the Servlet and get an Image back.
Would it be possible ? How to capture the image in your example, in EGL-Service?
Thank you very much for your attention !!
would it be something like that ??
package servlet;import java.io.IOException;import java.io.InputStream;import java.sql.Blob;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.servlet.ServletException;import javax.servlet.ServletOutputStream;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class BlobServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { request.setCharacterEncoding("UTF-8"); Blob photo = null; ServletOutputStream out = response.getOutputStream(); try { // photo = rs.getBlob(1); what ? response.setContentType("image/gif"); InputStream in = photo.getBinaryStream(); int length = (int) photo.length(); int bufferSize = 1024; byte[] buffer = new byte[bufferSize]; while ((length = in.read(buffer)) != -1) { System.out.println("writing " + length + " bytes"); out.write(buffer, 0, length); } in.close(); out.flush(); } catch (SQLException e) { response.setContentType("text/html"); out.println("<body><h1>Error=" + e.getMessage() + "</h1></body></html>"); return; } finally { } } }}
ojomenezes