Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6143461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:31:34+00:00 2026-05-23T18:31:34+00:00

I have a very simple custom JSP tag that I am using to generate

  • 0

I have a very simple custom JSP tag that I am using to generate pagination links. It goes roughly like:

<span id="${id}" class="paginationLinks ${cssClass}">
    <c:if test="${currentPage gt 1}">
        <!-- Links to previous page(s) -->
    </c:if>
    <span class="paginationCurrentPage">
        Page ${currentPage} 
        [DEBUG:  current=${currentPage}, 
                 total=${totalPages}, 
                 show=${currentPage lt totalPages} 
                 inverse=${currentPage gt totalPages}]
    </span>
    <c:if test="${currentPage lt totalPages}">
         <!-- Links to next page(s) -->
    </c:if>
</span>

The problem is that the links to go to the next page are not showing up after the first page (currentPage = 1). The links to go to previous pages are working correctly across every page. I’m also getting some truly bizarre output from my debug block:

[DEBUG: current=1, total=10, show=true inverse=false]    //first page, correct
[DEBUG: current=2, total=10, show=false inverse=true]    //second page; 2 > 10 == true?  wtf???
[DEBUG: current=9, total=10, show=false inverse=true]    //ninth page, still incorrect
[DEBUG: current=10, total=10, show=false inverse=false]  //tenth page, correct

Both currentPage and totalPages are request attributes of type long and are passed to the tag via declared tag attributes. So what have I done wrong to produce such insane output as 2 > 10 == true?

Update

It works correctly if I replace totalPages with a literal 10 in the comparison, but that really does not solve the problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:31:34+00:00Added an answer on May 23, 2026 at 6:31 pm

    Solution found. I needed to explicitly declare the type on my tag attributes, like:

    <%@ attribute name="currentPage" required="true" type="java.lang.Long" %>
    <%@ attribute name="totalPages" required="true" type="java.lang.Long" %>
    

    I suspect that without the declared type both attributes were being interpreted as Strings, and the tag was doing a lexicographical comparison between the string values of the numbers. I assume a literal value of 10 worked because the JSP interpreter recognized it as a proper numerical type and then automatically converted the other argument in the comparison to match.

    So long story short, always declare a type on your tag attributes. Otherwise very confusing things can happen.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm missing something fundamental here. i have a very simple custom class that draws
I have a very simple Java RMI Server that looks like the following: import
I have a very simple Storyboard with an Int32Animation that targets a custom DP
I have developed a very simple app that uses a custom adapter for a
I have a very simply subclass of UIButton that will fire off a custom
i have very simple problem. I need to create model, that represent element of
I have very simple select like this: SELECT * FROM table WHERE column1 IN
I have a very simple WPF application in which I am using data binding
I have a very simple bit of script that changes the status of an
I have a custom google map. It seems very simple. <!DOCTYPE html PUBLIC -//W3C//DTD

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.