• Post Reply Bookmark Topic Watch Topic
  • New Topic

Parsing a string array

 
Joshua Batchelor
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to write a contacts page similar to Yahoo's. I am getting all of a users contacts from the database and they are stored in a string array. Now the it is formatted like this firstname, lastname, nickname, homePhone#, mobilePhone#, officePhone#. Then the next contact. What is the best way to handle this within a JSP page? I tried string tokenizer but I don't know if I was doing it write any help would be great.
<% String[] contactList = (String[])request.getAttribute("contactList");%>
<%if (contactList != null) {
for (int i = 0; i < contactList.length; i++) {
%>
Contact: <%=contactList[i]%>">
<%}%>
<%}%>
 
Guoqiao Sun
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I do it, I might use Hashtable. Using username as the key, put User object ( which contains first name, last name, phone number ) and the key into the Hashtable. And store the Hashtable into request for later usage.
Just for your reference.
Regards,
Originally posted by Joshua Batchelor:
I am trying to write a contacts page similar to Yahoo's. I am getting all of a users contacts from the database and they are stored in a string array. Now the it is formatted like this firstname, lastname, nickname, homePhone#, mobilePhone#, officePhone#. Then the next contact. What is the best way to handle this within a JSP page? I tried string tokenizer but I don't know if I was doing it write any help would be great.
<% String[] contactList = (String[])request.getAttribute("contactList");%>
<%if (contactList != null) {
for (int i = 0; i < contactList.length; i++) {
%>
Contact: <%=contactList[i]%>">
<%}%>
<%}%>
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!