This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets 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: 19651
    
  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
 
It is sorta covered in the JavaRanch Style Guide.
 
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