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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get value from the string

Status
Not open for further replies.

GoSooJJ

Programmer
Feb 24, 2001
76
US
I have variable names coming from the textfile and trying to get the value from the servlet. For example, i have "custName" from the textfile and servlet page already have "custName" String variable and value. Is there way to make "custName" from the textfile to get value from the servlet?
Thank you.
 
Are you familiar with Java introspection? If not do a search for an overview of this technique. Using the java.lang.reflect package you can examine a classes public member variables (fields). The method .getFields() will help (see java.lang.Class)

getFields() Returns an array containing Field objects reflecting all the accessible public fields of the class or interface represented by this Class object.

The Field object is in java.lang.reflect, and will allow you to compare the name of the field with a String, see Field.getName().
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top