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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:22:36+00:00 2026-06-03T05:22:36+00:00

I have something like in my JSP page : <% if(id!=null) { %> <input

  • 0

I have something like in my JSP page :

<% if(id!=null) { %>
     <input type="hidden" name="id" value="<%= id %>" />
<%
}
%>

When I want to edit a user id should be non null, then I want that input in my HTML.
However, when I want to add a user id should be null, and so I don’t what that input.

It works great with that code. But I would like to use JSTL i tried using c:if and c:when :

<c:choose>
    <c:when test="${id != null }">
        <input type="hidden" name="id" value="<%=id%>" />
    </c:when>
    <c:otherwise>
        <br/>
    </c:otherwise>
</c:choose>

The problem is that this code displays <br /> when id is null or non null (add and edit) … And I don’t see why it doesn’t work.

Thanks for your help,

S

  • 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-06-03T05:22:37+00:00Added an answer on June 3, 2026 at 5:22 am

    The problem is that your variable id is not in a scope which jstl can reach.
    You need to do:

    pageContext.setAttribute("id", id);
    

    Also, it’s better to test against empty:

    <c:when test = "${!empty id}">
    

    And lastly, you should use jstl when outputting the value of id:

    <input type="hidden" name="id" value="${id}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My JSP page has many Submit buttons for example <input type=submit name=RemoveCustomer value=Submit/> <input
I have a JSP page where I want to say something like: <... onclick=alert('<bean:message
I have a JSP page at an address like this: http://example.com/foo/bar/rawr/something.jsp When I output
If you use dynamic pages like JSP or asp.net, you can have your page
I am just starting with Servlets/JSP/JSTL and I have something like this: <html> <body>
I'm working with Java and JSP. I have to create something like a promotion
I have a jsp page with the tags: <logic:iterate id=var ... .... <bean:write name=var
If you want to show content in JSP page based on user's access to
I have a jsp that contains a css link that looks like <link type=text/css
I have something like that: faces-config.xml <managed-bean> <managed-bean-name>aBean</managed-bean-name> <managed-bean-class>some.pack.Bean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> I have a

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.