This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

JSTL if statements not executed  RSS feed

 
Master Rancher
Posts: 1107
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most likely I constructed them wrong,  but I'm not to familiar with jstl and my ide dosn't let me debug jspfiles, since the don't belong to a class, but anyone knows why my if statements not being executed?
 
Sheriff
Posts: 24089
54
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like you're trying to do something different for the last entry in the list. It's possible that your first try there isn't working the way you hoped.

So I tracked down this JSTL tutorial: look for the bit about the varStatus attribute, which has an example of how to deal with the last entry in the list specially.
 
Daniel Demesmaecker
Master Rancher
Posts: 1107
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul, the tutorialat least gave me an idea of where to look (the tutorial itself I don't think is all that great)

This is how I fixed it:

Resulting in:
 
Saloon Keeper
Posts: 9710
192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm happy you figured it out. Let me just quickly point out that you don't want any styling mixed in with your content. Instead, move all styling to a stylesheet. This will make your JSP cleaner, and you can use pseudo-classes such as :first-child and :last-child so you don't even have to perform logic to do special styling for the first and last elements.
 
Daniel Demesmaecker
Master Rancher
Posts: 1107
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with the styling part, most of my css is in stylesheets, but sometimes I'm just to lazy and do small overide changes in the elements.
I disagree with not needing to do the check if I seperate my styling from my html.
I still need to know when to assign the stylingclass and in this case it would take more code to seprate the two then I need now.
Now at least in one of the cases it just takes 1 stylingproperty, while when seperating the two I would have to rewrite the whole div for both cases
 
Bartender
Posts: 20353
111
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's extremely to debug logic in a JSP with any IDE, which is one of the reasons why we discourage putting logic on a JSP at all. However, seeing as your logic is display-oriented rather than business-oriented, you don't have much of a choice.

This construct made me wonder:

it's confusing. And actually, it's probably not the best way to do that. As was mentioned by Paul, using named classes is tidier.

Incidentally, don't let the fools who say Thou Shalt Not Use Tables sway you. True, tables were abused in former days before we had div and span tags to act as containers, but when you have data that's actually a table, use the TABLE tag! It has the provisions to handle headers, footers, columns, and so forth in a much more straightforward way than stringing  together divs.
 
Daniel Demesmaecker
Master Rancher
Posts: 1107
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No offence, I respect your guys opinion and I know you guys know what you're talking about, but this is a personal project, no one else will ever work on it.
What I tried to do works and it's clear to me even when I would revisit the code in a couple of months I would still know what my intention was, so why would I change anything...?
 
Daniel Demesmaecker
Master Rancher
Posts: 1107
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To bad I'm bound by confidentiality, cause I would really like to show the project I'm working on at work...
You guys would get a heartattack and that's being used by the Belgian ministery of internal affairs...
Just to be clear the spaghetti code isn't my doing, It's written 13years ago, I'm part of the team that has to upgrade the technologies and clean up the code
 
Tim Holloway
Bartender
Posts: 20353
111
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Demesmaecker wrote:To bad I'm bound by confidentiality, cause I would really like to show the project I'm working on at work...
You guys would get a heartattack and that's being used by the Belgian ministery of internal affairs...



Spoiler. The EU is going to build a wall around England and Britain's going to pay for it.  
 
Paul Clapham
Sheriff
Posts: 24089
54
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Demesmaecker wrote:(the tutorial itself I don't think is all that great)



I agree. It's just the first one I found when I googled the problem. (I knew the answer was something like that because I recall using it myself, but that was probably close to 10 years ago now.)
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!