aspose file tools*
The moose likes JSP and the fly likes using string value as a variable name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "using string value as a variable name" Watch "using string value as a variable name" New topic
Author

using string value as a variable name

Prakash Balasubramani
Greenhorn

Joined: Sep 09, 2005
Posts: 8
Hi All,

How to convert a string into variable name. For example i have a variable named "myname" with value "sachin" in it i.e myname="sachin".

Then in an string i have a name of the variable. using this strings value how to print the name sachin. i.e if myString = "myname" how to print "sachin" using this string variable?

eg code:

myname = "sachin";

String myString = "myname";

i want out.println(myString) to print "sachin".

Thanks in advance for ur help.

Bye,

B.Prakash.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Print where?
stdout?
The webpage?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Prakash Balasubramani
Greenhorn

Joined: Sep 09, 2005
Posts: 8
I want to print it in WebPage
vidya sagar
Ranch Hand

Joined: Mar 02, 2005
Posts: 580
i hope it helps

StringBuffer myname = new StringBuffer();
name.append("sachin");
StringBuffer mystring = myname;
out.println(ename.toString());
g forte
Greenhorn

Joined: Aug 28, 2003
Posts: 25
String myname = "sachin";

String myString = myname; // get rid of the quotes so that you set myString equal to the value of myname, instead of setting myString equal to myname.

out.println(myString);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using string value as a variable name