简体   繁体   中英

How to display images as thumbnails from web content folder on a jsp page

Im trying to develop a gallery application where i have to access all the images in Web Content folder and display them as thumbnails on a jsp page. After displaying them on jsp page, when i click on any image it should be opened in a pop up window.

Can i develop this application just using a jsp or should i make use of servlet for rendering the images. Need the exact approach to develop this one.

I have been trying to find out ways to do this but couldn't get proper references. Can someone please tell me the ways to develop this and provide me with references that are close to my need. Appreciate your help.

This is what i have tried:

List imageUrlList = new ArrayList();  
File imageDir = new File("/myapp/images");  
for(File imageFile : imageDir.listFiles()){  
  String imageFileName = imageFile.getName();  

  // add this images name to the list we are building up  
  imageUrlList.add(imageFileName);  

}  
request.setAttribute("imageUrlList", imageUrlList);

<c:forEach var="img" items="${imageUrlList}">  
  <img >  
</c:forEach>

You need Jquery or other client side script to do this. Take a look at this one:

http://www.jssor.com/demos/image-gallery.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM