• 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
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

LocalDateTime.isAfter() method in JSP - NullPointerException  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Recently, I have had trouble comparing LocalDateTime instances using the predefined method isAfter().

I have tried the following in Eclipse and it works fine:



where stock is a JPA Entity with a LocalDateTime field that has a getter called getReserveDate().

Executing the following code in JSP(which I believe is identical to the line above) gives me a NullPointerException.



After debugging, I've managed to find out that the LocalDateTime.now() part of my code is considered null by JSP / JSTL but I have no idea why. This code works perfectly when ran in Eclipse but fails in a JSP.
 
Saloon Keeper
Posts: 10136
214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you know?

What happens if you output stock.getReserveDate() and LocalDateTime.now() on separate lines?
 
Sheriff
Posts: 24374
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You didn't say, but I suppose that you meant ${!compStock.getReserveDate().isAfter(LocalDateTime.now())} to be an EL expression. But it isn't. You can't just put arbitrary Java code in an EL expression and expect it to be treated as a Java expression.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!