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

  • SEARCH
  • Home
  • 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 4599292
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:31:12+00:00 2026-05-21T23:31:12+00:00

Is there a library or best-practice way of creating a menu with navigation links

  • 0

Is there a library or best-practice way of creating a menu with navigation links using JSTL?

I have 5 links that go on every page. I want the link that points to the current page to be “disabled”. I can do this manually but this must be a problem that people have tackled before. I wouldn’t be surprised if there is a taglib that handles it but I don’t know of it.

  • 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-21T23:31:13+00:00Added an answer on May 21, 2026 at 11:31 pm

    You can let JSTL/EL generate HTML/CSS conditionally based on the URL of the requested JSP page. You can get it by ${pageContext.request.servletPath} in EL. Assuming that you have the links in some Map<String, String> in the application scope:

    <ul id="menu">
        <c:forEach items="${menu}" var="item">
            <li>
                <c:choose>
                    <c:when test="${pageContext.request.servletPath == item.value}">
                        <b>${item.key}</b>
                    </c:when>
                    <c:otherwise>
                        <a href="${item.value}">${item.key}</a>
                    </c:otherwise>
                </c:choose>
            </li>
        </c:forEach>
    </ul>
    

    Or when you’re just after a CSS class

    <ul id="menu">
        <c:forEach items="${menu}" var="item">
            <li><a href="${item.value}" class="${pageContext.request.servletPath == item.value ? 'active' : 'none'}">${item.key}</a></li>
        </c:forEach>
    </ul>
    

    You can use <jsp:include> to reuse content in JSP pages. Put the above in its own menu.jsp file and include it as follows:

    <jsp:include page="/WEB-INF/menu.jsp" />
    

    The page is placed in WEB-INF folder to prevent direct access.

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

Sidebar

Related Questions

I'm looking for some best practice advice here. I have a library that I'd
I'm using a Java class library that is in many ways incomplete: there are
Is there any dolby/5.1/7.1 audio processing Python library? It would be best if it
Is there any library for distributed in-memory cache, distributed tasks, publish/subscribe messaging? I have
Is there a library/simple way to flip an image? Flip image like this: AABBCC
Is there a library that has a class to extract the text from a
Is there a library for Python that will allow me to parse c++ code?
What is the best practice when doing a mixed language library where the library
I have git projects that share a common library as a git submodule. When
What is the best practice for configuring a java class library? At my work,

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.