Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Concatenate method result , repeat in each Request

 
joseph prabhu
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

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.


Regards

Joseph Prabhu
 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We cant really help unless you post the request you are using.

Hunter
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no such thing as urgent.
What is the problem that you're trying to solve?
 
joseph prabhu
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

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.

Regards
Joe



that "","" is concatenning to final results at every request in browser i made. It is very strange.
>
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use code tags. You can edit your post with the button.
 
Mike Zal
Ranch Hand
Posts: 144
Fedora Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This looks like exact thing the StringBuilder class and append method was designed for.

EDIT: you never said what was wrong with your code. Can you provide some example of your inputs, intended outputs, and actual outputs?
 
Dan Din
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess: you try to eliminate the spaces between words separated by commas - if so, you need a jsonPData initialization after splitting into array.
Good luck,
D.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50225
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan Din, welcome to the Ranch
 
Enrico Savazzi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic