This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Variable Syntax Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Variable Syntax" Watch "Variable Syntax" New topic
Author

Variable Syntax

Alice Huber
Greenhorn

Joined: May 09, 2010
Posts: 9

I wish to give name attribute of <input> tag as variable depending on value of i. Kindly guide for the syntax.



Thanks
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
You need to add double quotes around +varfld+ .
Alice Huber
Greenhorn

Joined: May 09, 2010
Posts: 9
Tim,

Double quotes around +varfld+ does not resolve the issue.



Html code generated out of above code in Servlet is as below -



Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
I said "double quotes", not "escaped double quotes" - which renders them inoperable.
Alice Huber
Greenhorn

Joined: May 09, 2010
Posts: 9
Thanks Tim. Below code worked out.



Html Ouput is :
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

Slightly better is escaped double quotes and non-escaped double quotes:
The output will then also have quotes around the name attribute value.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
jQuery in Action, 2nd edition
 
subject: Variable Syntax
 
Similar Threads
send variable value from one servlet to another servlet for itext pdf
Getting null values in table even after the input
Run time checkbox values
calendar
calendar