Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How Solve utf-8 encoding problem

 
Ranch Hand
Posts: 32
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I used servlet for create login session. When i  enter username and password servlet call  home.jsp page. Then all other jsp pages have same problem.i add  code for all of them. But it doesnt solve problem. Please help me
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Nil. Hatamova wrote:But it doesnt solve problem.


What is the problem?
 
Nil. Hatamova
Ranch Hand
Posts: 32
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

Nil. Hatamova wrote:But it doesnt solve problem.


What is the problem?



It is UTF-8 encoding problem.In website i used unicode characters. But on a Tomcat server, utf-8 characters get mangled.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem with character encoding problems is that the cause of it can be in many different places. You have to be careful and check everything:

- What character encoding are your source JSP files saved in by your IDE? Is it UTF-8 or some other encoding (maybe the default encoding of your OS which might be different than UTF-8)?
- Where does the text come from? Is it static text that's directly in the JSP file or does it come from a database or some other source?
- If it's from a database, then what character encoding does the database use? And how are you getting it from the DB? Is the character encoding handled correctly in every step?
- If it's from a Java *.properties file, you have to be aware that class java.util.Properties treats *.properties files as if they are always encoded in ISO-8859-1. If you've saved the *.properties file using any other encoding, you'll get mangled text.

In my experience, many software developers don't understand character encodings and they often end up trying to solve a character encoding problem by adding "magic lines" to their code (lines of code which they don't understand, but just hope that they solve the problem). Don't do that - it's better to learn once and for all how character encodings work, and then you don't have to rely on magic lines which you don't understand.

Here's a good article that explains character encoding: What Every Programmer Absolutely, Positively Needs To Know About Encodings And Character Sets To Work With Text
 
Did you miss me? Did you miss this tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic