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 7604555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:56:23+00:00 2026-05-30T23:56:23+00:00

I am using jstl in order to create custom tag. Here is the content

  • 0

I am using jstl in order to create custom tag. Here is the content of location.tag:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ attribute name="id" required="true" %>
<%@ attribute name="locationType" required="false" %>
<br/>
<c:out value="${param.id}" /> <---THIS ALWAYS PRINTS NOTHING! WHY?
<br/>
<c:out value="${param.locationType}" /> <---THIS ALWAYS PRINTS NOTHING! WHY?
<br/>
<c:if test="${empty param.locationType}" >
    <select id="<c:out value="${param.id}" />_locationTypeSelect">
        <option value="ADDRESS">כתובת</option>
        <option value="INSTITUTE">מוסד</option>
    </select>
    <script type="text/javascript">
        $(document).ready(function() {
            $('<c:out value="${param.id}" />_locationTypeSelect').change(function() {
                switch($(this).val()) {
                    case 'ADDRESS':
                        $('<c:out value="${param.id}" />_addressCitySelect').show();
                        $('<c:out value="${param.id}" />_addressStreetSelect').show();
                        $('<c:out value="${param.id}" />_addressHouseNumberInput').show();

                        $('<c:out value="${param.id}" />_instituteNameSelect').hide();
                        $('<c:out value="${param.id}" />_instituteBranchSelect').hide();
                        break;
                    case 'INSTITUTE':
                        $('<c:out value="${param.id}" />_addressCitySelect').hide();
                        $('<c:out value="${param.id}" />_addressStreetSelect').hide();
                        $('<c:out value="${param.id}" />_addressHouseNumberInput').hide();

                        $('<c:out value="${param.id}" />_instituteNameSelect').show();
                        $('<c:out value="${param.id}" />_instituteBranchSelect').show();
                        break;
                }
            });
        });
    </script>
</c:if>

<c:if test="${empty param.locationType or param.locationType == 'ADDRESS'}" >
    <select id="<c:out value="${param.id}" />_addressCitySelect"></select>

    <select id="<c:out value="${param.id}" />_addressStreetSelect"></select>

    <input type="text" id="<c:out value="${param.id}" />_addressHouseNumberInput"/>
</c:if>

<c:if test="${empty param.locationType or param.locationType == 'INSTITUTE'}" >
    <select id="<c:out value="${param.id}" />_instituteNameSelect"></select>

    <select id="<c:out value="${param.id}" />_instituteBranchSelect"></select>
</c:if>

Here I am using the location tag:

<h:location id="a" locationType="ADDRESS"></h:location>
<h:location id="b"></h:location>
  1. For some reasons the generated ids of the elements doesn’t has the prefix <c:out value="${param.id}" />. For example, in location.tag I wrote <input type="text" id="<c:out value="${param.id}" />_addressHouseNumberInput"/> but the result of both the usages is: <input type="text" id="_addressHouseNumberInput"/> (it ignores the c:out. What is wrong?
  2. For the both usages the html result is the same, as if it doesn’t recognize the parameter locationType. Why is that?
  3. I have a lot of code duplication here. For example, all the id prefixes: <c:out value="${param.id}" />. Is there any way to reduce the amount of code?
  • 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-30T23:56:25+00:00Added an answer on May 30, 2026 at 11:56 pm

    The param variable you use there is an implicitly created map of the clients request parameters that got passed to the jsp. The attribute defined in your tag file is available without any prefix, so using

    <c:out value="${id}" />
    

    should be enough to output the correct value.

    If your supported jsp version is at least 2.0, you can also omit the c:out tag and directly use the el expression in text or attributess. The c:out would be required if you need xml escaping of the value, but since your seem to control the value of id this should not be an issue.

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

Sidebar

Related Questions

I am using http://java.sun.com/jsp/jstl/fmt tag library for outputting messages from Message Resource Bundle which
Using JSTL's forEach tag, is it possible to iterate in reverse order?
Good day! I tried using JSTL in java but there's an error: exception javax.servlet.ServletException:
I am trying to create a grid using JSTL <c:forEach> . <c:forEach var=user items=${userList}
I am using JSTL c:url tag to define my URL's in the application, something
I am trying to show the current date in my JSP page using JSTL.
What methods do I need to add to a custom Java class so that
is it possible to set a session attribute using JSTL from a hidden input
I am retrieving a value from our DB using JSTL. I am inserting it
I want to iterate a HashMap in javascript using jstl. is it possible to

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.