jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nandana Mihindukulasooriya" <nandana....@gmail.com>
Subject Displaying images stored in a Jackrabbit repository in a web page
Date Tue, 03 Jul 2007 15:21:28 GMT
         I am developing a blog application on Jackrabbit and my node
structure is as follows.

/blogRoot [nt:folder]
/blogRoot/<username> [blog:user]
/blogRoot/<username>/<yyyy> [nt:folder]
/blogRoot/<username>/<yyyy>/<mm> [nt:folder]
/blogRoot/<username>/<yyyy>/<mm>/blogEntry [blog:blogEntry]
/blogRoot/<username>/<yyyy>/<mm>/blogEntry/comment [blog:Comment]

        At the moment, a blog entry can have an image attachment and it is
stored  as a [nt:file] under the [blog:blogEntry] node. blog:blogEntry node
type is defined as follows

[blog:blogEntry] > nt:folder, mix:referenceable
- blog:title (string) mandatory primary
- blog:content (string) mandatory
- blog:rate (long)
- blog:created (date)
- blog:published (date)
- blog:updated (date)

       When I used relational databases, my approach was to save the file
name of the image in a table and store the physical file in the File System.
For example I generate a file name when a file is uploaded and store it's
name in the database in the relavant blog entry table.  So whenever I want
to generate the image in a web page in my web application, I can generate
<img src="/images/uploaded/"+imageFileName/>
if images are stored in the file system under /images/uploaded directory.

Is an approach like this possible with Jackrabbit if I store images under
blopgEntry node as described above. What are the other possibilities I have

This is the code I used to store the images,

// creates a blog entry under the current month
blogEntryNode = monthNode.addNode(title, "blog:blogEntry");
blogEntryNode.setProperty("blog:title", title);
blogEntryNode.setProperty("blog:content", content);
Value date = ValueFactoryImpl.getInstance().createValue(Calendar.getInstance
blogEntryNode.setProperty("blog:created",date );

// attach the image to the blog entry
Node imageNode = blogEntryNode.addNode(image.getName(),"nt:file");
Node contentNode = imageNode.addNode("jcr:content","nt:resource");

You expertise advice/comments are highly appreciated.Thank you very much in


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message