• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

String comparison in JBoss

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I'm facing a strange problem after having migrated a java/servlet application from Tomcat 5.5 to JBoss EAP 4.3.
Below is a code snippet which performs a string comparison:
...
if (stateCode.toUpperCase().equals("P�G�ENDE_EJ_KONTAKT")) return CaseStateCache.getInstance().getById(CaseState.STATE_INPROG_NOT_CONTACTED);
...
log.warn("Unknown state found in database:" + stateCode);
return CaseStateCache.getInstance().getById(CaseState.STATE_UNKNOWN);

And the log output is:
"...WARN [CaseDAO] Unknown state found in database:P�G�ENDE_EJ_KONTAKT..."

In the above, stateCode is read from an SQL Server 2000 (but should be irrelevant to this since the correct chars are written to the log file)

For you who can't read swedish characters, the string that stateCode is compared against and the state in the log, contains swedish characters (eg. å, ¨ and ö)

So , since the log shows that state spelled correctly, my suspicion is now that this might be due to some encoding and string comparison (that might differ from the encoding used when writing log to file), but I'm happy to receive your opinions and advice in this

Regards

/R
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The javadoc of String#toUpperCase() and toLowerCase has some details about locales. There's also an overloaded method which accepts the Locale.
 
Rickard Engstrom
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jaikiran Pai wrote:The javadoc of String#toUpperCase() and toLowerCase has some details about locales. There's also an overloaded method which accepts the Locale.



Thanks for reply, wil try that...

/R
 
Too many men are afraid of being fools - Henry Ford. Foolish tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic