• Post Reply Bookmark Topic Watch Topic
  • New Topic

%20f problem  RSS feed

 
ashu srivastava
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am querying city names from a table name country and displaying it as hyperlink. It is coming correctly.

But on clicking on any city it should some information which I bring from other tables. It works fine if City Name is not having any space, like Delhi, Mumbai etc.
But, when the City Name comes like - Montera Cty, ABC XYZ etc, then my program fails. I printed and found that these city names are going like Montera%20fCty, ABC%20fXYZ

Then, in my program, I removed the special character sequence "%20f" with space " ". Now, I am getting error Array Out of Bound Exception.

If anybody have any idea, please suggest how I can handle this problem or If I am doing anything wrong.

I will be very thankful.

Thanks in advance.
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The urls need to be url-encoded. See URLEncoder and URLDecoder.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you replace %20f by " " your String gets three characters shorter. You need to allow for that when counting characters, otherwise the index you are searching will fall off the end of the Sring.
 
ashu srivastava
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:When you replace %20f by " " your String gets three characters shorter. You need to allow for that when counting characters, otherwise the index you are searching will fall off the end of the Sring.


Hi Campbell,

I did not understand as I am not counting characters. I am just replacing "%20f" with a space because City names are stored like that in Database, like ABC XYZ, Montera Cty etc.

May be I have not understood properly what you want to convey. Please suggest.


Thanks,
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!