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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:00:38+00:00 2026-06-11T18:00:38+00:00

I am using JSP and Spring framework. In a page, I want to have

  • 0

I am using JSP and Spring framework. In a page, I want to have five buttons next to a corresponding select element. My question is how can I avoid repeating the code for that?

Here is the code I have for one button-select combination:

       <tr>
            <td>
                <sf:label path="inputFile">Select a file:</sf:label>
            </td>
            <td>
                <sf:select path="inputFile" cssStyle="width: 250px;" onchange="enableLocal(this.selectedIndex,'matButton')">
                    <sf:option value="Upload a Local File" />
                    <sf:option value=" --- Available already: --- " disabled="true" />
                    <sf:options items="${flowData.availableInputs}" />
                </sf:select>
            </td>
            <td>
                <input id="matButton" type="file" name="inputFile"/>
            </td>
        </tr>

In the above code, the names inputFile and matButton are to be treated as parameters, i.e., other buttons will have different names.

What I have in mind is something like a function with the two parameters that would generate the above code. Is it possible?

  • 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-11T18:00:39+00:00Added an answer on June 11, 2026 at 6:00 pm

    Create a custom JSP tag file.

    /WEB-INF/tags/file.tag

    <%@ tag body-content="empty" %>
    <%@ attribute name="selectPath" required="true" type="java.lang.String" %>
    <%@ attribute name="buttonId" required="true" type="java.lang.String" %>
    <%@ taglib prefix="sf" uri="...???..." %>
    
    <tr>
        <td>
            <sf:label path="${selectPath}">Select a file:</sf:label>
        </td>
        <td>
            <sf:select path="${selectPath}" cssStyle="width: 250px;" onchange="enableLocal(this.selectedIndex,'${buttonId}')">
                <sf:option value="Upload a Local File" />
                <sf:option value=" --- Available already: --- " disabled="true" />
                <sf:options items="${flowData.availableInputs}" />
            </sf:select>
        </td>
        <td>
            <input id="${buttonId}" type="file" name="inputFile"/>
        </td>
    </tr>
    

    (I have no idea what that sf taglib is, you’ve to complete its URI yourself)

    Use it as follows where file is the base filename of the .tag file:

    <%@ taglib prefix="my" tagdir="/WEB-INF/tags" %>
    ...
    <my:file selectPath="inputFile" buttonId="matButton" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Spring MVC 3.0 I have a guestbook.jsp page where I want
I'm using Spring Web Flow (v. 1.0.5) and I have a JSP page that
I'm using Spring MVC. I want to include menu page (named menu.jsp) with a
I'm using Eclipse/Spring source to edit JSP tags and EL. If I want to
Using Spring as Framework, if i need provide business logic's service to either JSP/Servlets(on
I have some problems using ajax with Spring MVC. I want to refresh only
I am using spring framework 3. I have a form for posting comments to
I am using Java EE with Spring framework. I have been setting up a
I am using Struts 2-Spring framework in my assignment. I have defined a bean
I am using Spring in my JSP project: I have following mapping for all

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.