• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 175
  • Last Modified:

using variables as values in a form control

I've a form which is created in a while loop. I would like to use one of the variables generated in the while loop as a value in the text area of my form control. My code is as follows:
String myName;
While (condition){
myName = "name"+i;
out.println("<td>" + "<form name='form1'>"+ "<textarea name="text1" value="<%=myName%>">"+"</td>");
i++;
}
This code generates the following error:
unclosed string literal       "<textarea name="text1" value=\"<%=i

How can i resolve this?
0
VbMonk
Asked:
VbMonk
1 Solution
 
ldbkuttyCommented:
make it like this:

out.println("<td>" + "<form name='form1'>"+ "<textarea name=\"text1\" value=\""+myName+"\">"+"</td>");

you cannot have <%=somthing%> inside your JSP. Its used to print inside the HTML. for example, this is correct format:

<%
  String myName;
  While (condition){
     myName = "name"+i;
%>
      <td> <form name='form1'> <textarea name="text1" value="<%=myName%>"> </td>
<%
      i++;
   }
%>
0
 
VbMonkAuthor Commented:
It worked. No errors!!!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now