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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:51:13+00:00 2026-05-11T14:51:13+00:00

When trying to use a custom JSP tag library, I have a variable defined

  • 0

When trying to use a custom JSP tag library, I have a variable defined in JSP that I would like to be evaluated before being passed to the tag library. However, I cannot seem to get it to work. Here’s a simplified version of my JSP:

<% int index = 8; %>  <foo:myTag myAttribute='something_<%= index %>'/> 

The doStartTag() method of my TagHandler uses the pageContext’s output stream to write based on the inputted attribute:

public int doStartTag() {     ...     out.println('Foo: ' + this.myAttribute); } 

However, the output I see in my final markup is:

Foo: something_<%= index %> 

instead of what I want:

Foo: something_8 

My tag library definition for the attribute is:

<attribute>     <name>myAttribute</name>     <required>true</required> </attribute> 

I have tried to configure the attribute with rtexprvalue both true and false, but neither worked. Is there a way I can configure the attribute so that it’s evaluated before being sent to the Handler? Or am I going about this totally wrong?

I’m relatively new to JSP tags, so I’m open to alternatives for solving this problem. Also, I realize that using scriptlets in JSP is frowned upon, but I’m working with some legacy code here so I’m kind of stuck with it for now.

Edit:

I have also tried:

<foo:myTag myAttribute='something_${index}'/> 

which does not work either – it just outputs something_${index}.

  • 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. 2026-05-11T14:51:13+00:00Added an answer on May 11, 2026 at 2:51 pm

    I don’t believe that you can use a <%= ... %> within an attribute in a custom tag, unless your <%= ... %> is the entire contents of the attribute value. Does the following work for you?

    <% int index = 8; %> <% String attribValue = 'something_' + index; %>  <foo:myTag myAttribute='<%= attribValue %>'/> 

    EDIT: I believe the <% ... %> within the custom tag attribute can only contain a variable name. not any Java expression.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try strcasecmp(). Here's the manual page for it. It is… May 12, 2026 at 11:17 pm
  • Editorial Team
    Editorial Team added an answer Some ideas off the top of my head: BigSpender st@tement… May 12, 2026 at 11:17 pm
  • Editorial Team
    Editorial Team added an answer x = B[0] y = B[1] A[x][y] May 12, 2026 at 11:16 pm

Related Questions

I'm working in a very simple and small web application, it is a jsp
I've recently inherited an application that makes very heavy use of session, including storing
I'm trying to use a custom maven wagon extension to deploy a jar to
I'm trying to load a custom log.properties file when my application is started. My

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.