Hello all. I have a hashtable. It consists of the keys which are usernames and the other user data in tokenized format.
ie/ SALLY 1423{%}SALLY{%}JOHNSON{%}ABC COMPANY{%}
JOAN 1432{%}JOANUS{%}SMITH{%}CDE COMPANY{%}
I'm trying to create a table on my jsp page that lists the username and each of the additional fields separately. Then problem is that when I pass the second field of the hashtable to the StringTokenizer I get this error.
Explicit cast needed to convert java.lang.Object to java.lang.String.
Apparently the non-key field from the hashtable is not treated as a string. Does anyone know what method I can call to convert this to a string and send it to StringTokenizer()? My code is below.
Please Note: I declare the bean used to get the user params prior to all of this code...
...
<%!
public Hashtable ht_userdata;
Enumeration usernames;
public String str = " "; %>
<%
ht_userdata = new Hashtable();
UserData UDO = new UserData();
//user_search method returns the hashtable
ht_userdata = UDO.user_search(udb.getcriteria(), udb.getstype());
usernames = ht_userdata.keys();
while(usernames.hasMoreElements()) {
str= (String) usernames.nextElement();
String s = ht_userdata.get(str);
StringTokenizer st = new StringTokenizer(s, "{%}"
; //ERRORS HERE
while (st.hasMoreTokens()) {
String userid = st.nextToken();
String password = st.nextToken();
String u_startdate = st.nextToken();
String u_enddate = st.nextToken();
String company = st.nextToken();
String u_firstname = st.nextToken();
String u_lastname = st.nextToken();
}
%>
... blah blah blah
<%
}
%>
Any help would be greatly appreciated.
Thanks!
CrystalVisualBOracle
ie/ SALLY 1423{%}SALLY{%}JOHNSON{%}ABC COMPANY{%}
JOAN 1432{%}JOANUS{%}SMITH{%}CDE COMPANY{%}
I'm trying to create a table on my jsp page that lists the username and each of the additional fields separately. Then problem is that when I pass the second field of the hashtable to the StringTokenizer I get this error.
Explicit cast needed to convert java.lang.Object to java.lang.String.
Apparently the non-key field from the hashtable is not treated as a string. Does anyone know what method I can call to convert this to a string and send it to StringTokenizer()? My code is below.
Please Note: I declare the bean used to get the user params prior to all of this code...
...
<%!
public Hashtable ht_userdata;
Enumeration usernames;
public String str = " "; %>
<%
ht_userdata = new Hashtable();
UserData UDO = new UserData();
//user_search method returns the hashtable
ht_userdata = UDO.user_search(udb.getcriteria(), udb.getstype());
usernames = ht_userdata.keys();
while(usernames.hasMoreElements()) {
str= (String) usernames.nextElement();
String s = ht_userdata.get(str);
StringTokenizer st = new StringTokenizer(s, "{%}"
while (st.hasMoreTokens()) {
String userid = st.nextToken();
String password = st.nextToken();
String u_startdate = st.nextToken();
String u_enddate = st.nextToken();
String company = st.nextToken();
String u_firstname = st.nextToken();
String u_lastname = st.nextToken();
}
%>
... blah blah blah
<%
}
%>
Any help would be greatly appreciated.
Thanks!
CrystalVisualBOracle