Announcement Announcement Module
Collapse
No announcement yet.
velocity + diplay imges stored as blob Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • velocity + diplay imges stored as blob

    Hi all,

    I want to retrieve images from db(which are stored as blob datatype) and display on web page. After reading from db, I have stored image as byte[] in TO. I want to render it using velocity template. Could anybody suggest me how to proceed further.
    Any help is appreciated.

    Thanks,

  • #2
    Originally posted by yoshu
    Hi all,

    I want to retrieve images from db(which are stored as blob datatype) and display on web page. After reading from db, I have stored image as byte[] in TO. I want to render it using velocity template. Could anybody suggest me how to proceed further.
    Any help is appreciated.

    Thanks,
    Why use a velocity template to render an image? If this for a web application/rich client etc?

    If it is for a web you will probably find it easier to have a dedicated image Servlet/Controller that simply writes the byte[] to the response.

    The problem is that you cannot embed images in HTML, you must embed the URL to the image, not the image itself.

    Give a bit more info

    Comment


    • #3
      hi,

      Thanks for ur quick reply. I am using spring and velocity to develop search engine. Depending on certain criteria i need to display few images and related info from database. If at all it is not possible with velocity, how do I use servelet with my controller.
      Thanks,

      Comment


      • #4
        Originally posted by yoshu
        hi,

        Thanks for ur quick reply. I am using spring and velocity to develop search engine. Depending on certain criteria i need to display few images and related info from database. If at all it is not possible with velocity, how do I use servelet with my controller.
        Thanks,
        I presume this is web based then?

        If so you need to map your imageServer servlet or controller to (e.g.) /images

        and then in your search results page you need to create html markup which contains something like:

        Code:
          <img src="images?imageId=12345">
        So yes, you can use velocity to generate the markup, but I wouldn't use it to render the image.

        Of course; there are exactly 5653881 ways to skin a cat, so other people will do it differently

        Comment


        • #5
          I have used the same method as yatesco and I am pretty pleased with it. You can isolate the image displaying code inside a DAO and reuse it across the entier application plus it works well with bookmarks.

          Comment


          • #6
            Originally posted by costin
            I have used the same method as yatesco.
            Is this a case of "Great minds think alike" or "fools seldom differ"

            Comment


            • #7
              thanks a lot. It works..

              Comment

              Working...
              X