using variables as values in a form control

Posted on 2004-11-10
Last Modified: 2010-04-01
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>");
This code generates the following error:
unclosed string literal       "<textarea name="text1" value=\"<%=i

How can i resolve this?
Question by:VbMonk
    LVL 32

    Accepted Solution

    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>

    Author Comment

    It worked. No errors!!!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    This post first appeared at Oracleinaction  ( Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
    Great sound, comfort and fit, excellent build quality, versatility, compatibility. These are just some of the many reasons for choosing a headset from Sennheiser.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now