Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Servlet -> JSP variable

Status
Not open for further replies.

zekmes

Programmer
Nov 24, 2011
1
RO
Hi! Can someone help me? I'm a starter in Java-WebDeveloping and i have a question.
I have some Strings in a servlet that i want to send to a JSP (with setAttribute()). So far so good. After this, i want to show them in my JSP. Because there are a variable number of them i need to make a for.

<%
for(int i=1;i<=j;i=++){
%>
Contine: <input type="text" name="<%out.print("Aller"+i);%>" value="<%out.print("${Message"+i+"}");%>" readonly="readonly"/>
<%
}
%>

All variables here are ok, tested...But my JSP instead of showing me the attribute i set in the Servlet, i get ${Message1}. The conclusion is that the JSP does the commands in order, and it doesn t know what ${Message1} means because it passed to next lines of code.
Does anyone knows how to make "<%out.print("${Message"+i+"}");%>" work?

P.S. Sorry for my english, it's not my native language
 
I'm not very sure about what you're trying to do exactly, but here you have an example that may help you.

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top