Meaningless Drivel is fun!
The moose likes JSP and the fly likes generate tag ids dynamically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "generate tag ids dynamically" Watch "generate tag ids dynamically" New topic

generate tag ids dynamically

Utkarsh Jauhari

Joined: Jan 12, 2013
Posts: 2
I am new Please hellp !!!

can we use something like
y is a variable
out.println(<input type=/'text/' id=/'name"+y+"/'>);
out.println(<input type=/'text/' id=/'name<%=y%>/'>);

Actually i want to generate tag id's dynamically for form inputs(which are generating dynamically too) for further value retrieval through javascript.

var temp=document.getElementById("name1").value;
var temp1=document.getElementById(name2).value;

Please reply soon. Thanks in Advance
Vijay Vishwa
Ranch Hand

Joined: Nov 21, 2010
Posts: 32
Hi Utkarsh,

Please do you the code tag when putting any code.
Regarding the question.

OR if using the " (double quotes to given the value to properties) then

Note the use of escape sequence \ (its not /)

If you are wrting in JSP then you can also use

SCJP 5.0 OCBCD 5.0(Formerly SCBCD)
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63868

Why are you using out.println in the first place? That's really strange. The whole point of a JSP is not to have to create HTML in strings! Just put the HTML in template text.

Also, using Java scriptlets in JSPs is an obsolete practice from over 10 years ago! Time to modernize your skills with the JSTL and EL. Please see this JspFaq entry.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: generate tag ids dynamically
It's not a secret anymore!