This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Dynamically assign a name to a textfield  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to write a JSP that contains a struts 2 textfield tag as follows:

I would like to dynamically assign a name to this textfield using the value of a variable I declare earlier in the code as follows:

I would like to give the textfield a name that is equal to the current value of the variable i.
Please advice.
 
Author and ninkuma
Marshal
Posts: 66797
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
RohitPrakash Shinde
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But this is a JSP question.. I am using it with the Struts 2 framework but this has nothing to do with the struts framework . Therefore, I thought it to be a JSP question and hence posted it in the JSP forum.
 
Sheriff
Posts: 23692
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP question? Well, normally in JSP with the EL the name of the variable would be simply

But for some reason you've thrown some scriptlets in there. Normally in JSP with the <c:forEach> element you'd use the varStatus attribute to give you a variable which you can get the index number from, so you shouldn't need a scriptlet.

But you aren't using <c:forEach>. You're using a Struts iterator. So your Struts question is "How do I get a value which represents the number of times the code has been through the loop from an <s:iterator> element?"

So it's a Struts question.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!