How to display a list of images according to rows and columns

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ha Nguyen
    New Member
    • Aug 2009
    • 21

    How to display a list of images according to rows and columns

    Hi all,
    Eg: I have a list which contains 4 images (this list is got from database), I want to display them in 2 columns (1 image/col and only 2 columns/row):
    Img1 | Img2
    Img3 | Img4

    And if I have more 4 images they are displayed follow:
    Img1 | Img2
    Img3 | Img4
    img5 ...
    Pls help me.
    Thanks in advance,

    Ha
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    What have you done so far?

    Comment

    • Ha Nguyen
      New Member
      • Aug 2009
      • 21

      #3
      Sorry r035198x,
      I dont get you. What do you mean?
      That is a requirement i received. they require me create a page that displays a list of images on only 2 columns and unlimited rows.
      We use <data:iterato r ...> and <data:data ...> tags to list data from component java file to jsp file.
      Now I have got data from database already but i dont know how to list the images as newspaper columns.
      Pls help me.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        What attempts have you already made at displaying the images and at what specific point are you stuck?
        Also state the technologies you are using in your application.

        Comment

        • Ha Nguyen
          New Member
          • Aug 2009
          • 21

          #5
          Originally posted by r035198x
          What attempts have you already made at displaying the images and at what specific point are you stuck?
          Also state the technologies you are using in your application.
          Now I got the data (images name) from database and set them to a dataContext. we saved images in a folder inside of the project.
          The problem is how to display that images on the .jsp page according to rows with 2 or 3 columns/row.
          Eg: display 3 images / row.
          I tryed in alot of ways but not correctly.we use the servlet technology for the project.(if did i understand your mean?)
          Pls help me.

          Ha

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            One approach is to use tables in your JSP with the appropriate number of rows and columns. In each <td> you'd then put and <img> tag whose src attribute points to an image serving servlet passing the row/column numbers to let it know which image to display.
            Something like
            Code:
            <img src="/ImageServlet?location=1:3" />

            Comment

            • Ha Nguyen
              New Member
              • Aug 2009
              • 21

              #7
              Thanks so much r035198x, I will try now.

              Ha

              Comment

              Working...