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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:57:48+00:00 2026-05-11T01:57:48+00:00

I have a JSP that is using Spring:form tags to bind controls to a

  • 0

I have a JSP that is using Spring:form tags to bind controls to a command object.

I would like to modify it as follows: if [some condition is true] than display the controls; otherwise, just display the text. (Examples: if the user is an Admin, display the controls, otherwise just display the text. If the whatsit is still open for modification, display the controls, otherwise display the text.)

In other words, I want this:

<c:choose>      <c:when test='SOME TEST HERE'>           <form:input path='SOME PATH' />      </c:when>      <c:otherwise>           <p>${SOME PATH}</p>      </c:otherwise> </c:choose> 

But I want an easy way to create this for every field (there are many).

If I create a custom tag to generate the above text (given ‘SOME PATH’), will the Spring custom tags get bound?

I guess what I’m really asking is: can I create custom tags that generate Spring custom tags that then get bound? Or do all custom tags (mine and Spring’s) get handled simultaneously?

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T01:57:48+00:00Added an answer on May 11, 2026 at 1:57 am

    Frequently the only solution is to try it.

    I tried it three different ways — a JSP custom tag library, a parameterized JSP include, and a JSP2 tag file.

    The first two didn’t work (although I suspect the tag library can be made to work), but the tag file did! The solution was based loosely on an example given in Expert Spring MVC and Web Flow.

    Here’s my code in WEB-INF/tags/renderConditionalControl.tag :

    <%@ tag body-content='tagdependent' isELIgnored='false' %> <%@ attribute name='readOnly' required='true' %> <%@ attribute name='path' required='true' %> <%@ attribute name='type' required='false' %> <%@ attribute name='className' required='true' %> <%@ taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core' %> <%@ taglib prefix='fmt' uri='http://java.sun.com/jsp/jstl/fmt' %> <%@ taglib prefix='form' uri='/WEB-INF/spring-form.tld' %> <%@ taglib prefix='spring' uri='/WEB-INF/spring.tld' %>  <c:if test='${empty type}'> <c:set var='type' value='text' scope='page' /> </c:if>  <spring:bind path='${path}'>     <c:choose>         <c:when test='${readOnly}'>             <span class='readOnly'>${status.value}</span>         </c:when>         <c:otherwise>            <input type='${type}' id='${status.expression}' name='${status.expression}'                     value='${status.value}' class='${className}' />         </c:otherwise>     </c:choose> </spring:bind> 

    And here’s the code in the jsp:

    First,with the other taglibs directives:

    <%@ taglib tagdir='/WEB-INF/tags' prefix='tag' %>  

    and within the form:

    <tag:renderConditionalControl path='someObject.someField' type='text' readOnly='${someBoolean}' className='someClass' /> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 68k
  • Answers 68k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Sinatra is a much smaller, lighter weight framework than Rails.… May 11, 2026 at 12:20 pm
  • added an answer symsrv.dll is responsible for loading symbols from a symbol server… May 11, 2026 at 12:20 pm
  • added an answer On your local server run this: python manage.py dumpdata flatpages… May 11, 2026 at 12:20 pm

Related Questions

Right now I have a JSP page that allows to sort some items, when
I have a block of JSP code that needs to be used in several
So in struts I have an action form which has 5 properties. Each property
What's the proper way to create a hyperlink in Spring+JSP? There must be a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.