I use some some string concatenation(plus operator or concat method) Using String class. and have final output and it is return to jsp. Whenever new request is made the results of concat method alone get repeated for each request. How can be overcome this? Please suggest it is very urgent.
There is no such thing as urgent.
What is the problem that you're trying to solve?
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Joined: Feb 26, 2008
My code is below
see the second for loop , i am using concat method and concatenning the ""," to the individual string and final string is set in a request attribute and in jsp using that attribute and printing in browser.
Can some body help.
that "","" is concatenning to final results at every request in browser i made. It is very strange.
I also have trouble understanding what you are trying to accomplish. In any case, assuming that
(note that some of the spaces are repeated multiple times) your code produces the output:
:This, is , a , test.This","is","a","test.
To me, it looks like the code does exactly what I would expect it to do, i.e. splits the original string into a string array on commas, strips away the leading and trailing spaces of each array element (first for loop), appends "," to each element array but the last (second for loop), and finally tacks all element arrays onto the original string (third for loop).
Assuming you want instead to produce "This","is","a","test." simply do: