1

I am currently working with Stripes and I have an ActionBean that loads a specific User object JavaBean (Email, First Name, Last Name, Blob image) from my database according to a parameter in the url. This ActionBean then forward to a JSP page that displays these information by using the ActionBean and accessing the User object instance (property of the ActionBean).

I have no problems displaying the text data (Email, First Name and Last Name) but I don't really know how I can display the Blob image (it's a byte array) dynamically.

Is there a way, maybe using a tag from the Stripes Tag lib to load a event (Resolution) that would load the image from the current ActionBean and display it when the page is loaded?

I thought I could call an Resolution (event) from the User JavaBean as the src of the tag but he doesn't seem to work...

public Resolution loadPicture(){
    StreamingResolution sr = null;

       return sr = new StreamingResolution("image/jpeg") {
             public void stream(HttpServletResponse resp) throws Exception {
                 OutputStream os = resp.getOutputStream();
                 os.write(this.user.getBlob());
                 os.close();
             }
         };
}

Thanks in advance!

1 Answer 1

3

That's not how HTTP and HTML works. A request is used to load the HTML code. This HTML code contains various <img src="..." /> tags, and a new request is made to load each image. You must generate HTML with img tags that have their src point to a Stripes action which will load the image and stream it to the response.

A StreamingResolution is the right approach to implement this action, but the action will have to be called from another request.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.