Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: LocalDateTime.isAfter() method in JSP - NullPointerException

  1. #1
    Junior Member
    Join Date
    Mar 2019
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default LocalDateTime.isAfter() method in JSP - NullPointerException

    Recently, I have had trouble comparing LocalDateTime instances using the predefined method isAfter().

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

    stock.getReserveDate().isAfter(LocalDateTime.now())

    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.

    <c:when test="${compStock.getReserveDate().isAfter(LocalDateTime.now())}">
        <p>Stock is reserved!</p>
    </c:when>


    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.
    Last edited by bida2; March 31st, 2019 at 04:29 AM.

Similar Threads

  1. How to block the JSP being called by GET method
    By aswinraj11 in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: May 23rd, 2014, 12:40 AM
  2. To call java method in jsp
    By Rajeshkumar in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 28th, 2014, 07:35 AM
  3. Spring 3.2 -- 404 error calling a controller method from a link in a JSP
    By FHSerkland in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 12th, 2013, 07:00 AM
  4. Jsp Servlet problem with getting parameter vaules from another jsp page
    By venkat_tk in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: February 25th, 2013, 02:51 AM
  5. Parent JSP Page is not refreshing properly after modifying a child Jsp.
    By jay_84 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 14th, 2011, 09:59 AM