My problem is I have a cache file that I'm pulling in from a seperate source. The cache contains a long string that would look something like this except much longer.

myexample=1 status=0 timesHit=2500

Basically I need help figuring out how to break this up into
myexample=1
status=0
timesHit=2500

The java code is written inside of html code but I know the html code well enough.
I don't think this is overly complicated but I just can't seem to get it to work.

<%
		final CacheManager cacheManager = CacheManager.getInstance();
  		String[] names = cacheManager.getCacheNames();
  		Arrays.sort(names);
  %>			
<%	
		for (int i = 0; i < names.length; i++) { 
			Cache cache = cacheManager.getCache(names[i]);
  %>
  			<table border="1" bordercolor="#cc0000">
  			<tr class="tan">
  			<td colspan="3">
			
      			<div class="largeHeader2"> Cache <%= i %>: <%=names[i]%> </div>
      			<div class="smallCopy"> <table>
		<%	
			[B]String info;
			String line = cacheManager.getCache(info);
			for(j = 0; j < parts.length; j++) {
			String [] parts = line.split(" ");[/B]
			}
		%>

the bolded part is the part i've edited. Everything else should be correct. The bold part is the part I'm having trouble with.
The bold is very wrong but I have been trying to figure this out for many hours so this is desperation code.

The original code looked like this so that you can see the parts i have screwed up.

<%
		final CacheManager cacheManager = CacheManager.getInstance();
  		String[] names = cacheManager.getCacheNames();
  		Arrays.sort(names);
  %>			
  <%	
		for (int i = 0; i < names.length; i++) { 
			Cache cache = cacheManager.getCache(names[i]);
  %>
  			<table border="1" bordercolor="#cc0000">
              <tr class="tan">
              <td colspan="3">
            
                  <div class="largeHeader2"> Cache <%= i %>: <%=names[i]%> </div>
                  <div class="smallCopy"> <%= [B]cache[/B] %> Total elements cached currently: <%= cache.getKeysWithExpiryCheck().size() %> </div>
            </td>
  			</tr>

the bolded cache is what i change and where i need to add the new code.

I hope this doesn't sound too newby but have you tried looking into String Tokenizer? i'm assuming the information is in Strings so you can learn the StringTokenizer class to seperate your string based on a " " or space token.

Oh wait it looks like you're using Javascript... I don't know of any JavaScript classes/functions to help you X_X

You do not need to use "split()" in a for loop

<%	
	String info;
	String line = cacheManager.getCache(info);
	for(j = 0; j < parts.length; j++) {
	String [] parts = line.split(" ");
	}
%>

Just use this code instead:-

<%	
	String info;
	String line = cacheManager.getCache(info);
	//for(j = 0; j < parts.length; j++) {
	String [] parts = line.split(" ");
	//}
%>

Note:-
I have commented out the for loop here
And by the have you noticed how you are using the "parts" object(in the for loop) before actually declaring it (which is inside the loop).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.