Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Looping in jstl with condition choosing by String From the List  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello i have folder for images and all image names and attributes are added in a List, the main problem i would like to loop in the List and choose only images that are specific for some kind, as example in the Photo folder i have photos for 1.spices,2.beverages,3.chess and so on. please check the list<> i want to upload all images in the same folder and when needed want to show just the section of chess or Spices, the main issue regarding JSTL, i tried and got all the images, i added some conditions but now i'm confused, so please if you can help show me the right way i will be pleased






[/code]
 
Ranch Hand
Posts: 207
2
Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's probably a much better idea to organize it in the servlet, then you can have your sections for different types with their own array of items. 
 
Bartender
Posts: 19733
92
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Al Hobbs wrote:It's probably a much better idea to organize it in the servlet, then you can have your sections for different types with their own array of items. 



If you do not wish to antagonize the Bear, use the JSP as a View Template and put the Model Data into JavaBeans created and managed by a Controller Servlet. If you put logic on the View Template (JSP), you will offend him.

Actually, although I prefer other frameworks, no matter which framework you use, don't put logic on the View. When you do this A) it's a  to debug, since JSPs are not designed to be executed/debuggable code units and B) you've created a "Treasure Hunt" situation where you have to bop around looking for what gets done where. Was it in the JSP? Was it in the servlet? Ganesha help me! It's both! if I change it here, I have to remember to change the corresponding other part over there! And forget about sharing the resource anywhere else, because then you're hunting Easter Eggs.
 
Author and ninkuma
Marshal
Posts: 66806
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:
If you do not wish to antagonize the Bear, use the JSP as a View Template and put the Model Data into JavaBeans created and managed by a Controller Servlet. If you put logic on the View Template (JSP), you will offend him.



Never poke the bear!

Seriously, head over to this article to read about how Java servlet/JSP apps should be organized.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!