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

Recipe 4 strange characters ?

 
Roel De Nijs
Sheriff
Posts: 10593
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have in a html form a combobox with the name of some streets, one of these streets is "AVOU�STRAAT". When i ask source of this html-page i get for this item:


when i select this value and submit the form and take a look in the set-method of the according Struts ActionForm, the value is set to "AVOU�‰STRAAT" and that's not "AVOU�STRAAT", so the rest of the processing won't work anymore.

Anybody with an idea or suggestion to solve this irritating problem?

With friendly regards.
 
Michael Arndt
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you provide some information about your

- client-os
- server-os
- browser

and how dou you examine the value in the corresponding setter in the action form? by logging the value to a file or by setting a breakpoint and debugging the code? remember, logging can cause some trouble regarding the charset, too...

regards,
michael
 
Roel De Nijs
Sheriff
Posts: 10593
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
client-os = win2000 professional SP4
server-os = win2000 server SP4
browser = IE6.0 SP1

i did the checking by placing a breakpoint in the set-method and the value that's coming in contains the weird characters
 
Trevor Whitehead
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your using the Bean tags or HTML tags in your iteration set the filter attribute to true. Check out web page
for more information.
 
Michael Arndt
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Trevor: The option-Tag does not support the filter-Attribute :-(

let's have a look.
Examine the characterset you are using to save your files. standard might be iso-8859-1, us-ascii or something like this. Try to save the files in iso-8859-1 (LATIN-1).

use this in your jsp-page:

<%@ page pageEncoding="iso-8859-1" %>

this assures a header to be sent to the client telling the page's character encoding is "iso-8859-1". Some servers will not allow these headers to be sent so you can additionally add this (quite early) to your page's <HEAD>-section:

<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

The page should be displayed correct now.

When sending back the form's content the byte stream encoded by the browser must be interpreted by your application server that builds up the HttpServletRequest-Wrapper including parameters etc. When using Tomcat, you can examine the charset used by reading the file:
$CATALINA_BASE/server/lib/catalina.jar$org.apache.catalina.util.CharsetMapperDefault.properties.
Dependent on the client's accept-language-request-header the specified charset will be used to build up the Strings.

Information about encoding can also be found here:

http://www.w3.org/TR/html401/charset.html

There is also a way to tell which encodings the server should accept:

<html:form action="/anAction.do" acceptCharset="iso-8859-1">...</...>

And you can tell the system which defaultEncoding to use:

e.g.: java -Dfile.encoding=CP1252

wow. encoding is never funny. maybe you can find out what's the problem. let us know!

Hope it helps you on the way,

Michael
 
Roel De Nijs
Sheriff
Posts: 10593
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Trevor

Thanks for your suggestion. I use the optionsCollection-tag who supports the filter-attribute.
I tried it with both "false" and "true", but none of both did solve the problem.

Now i am trying to take a look at the comments of Michael.

I'll stay in touch
 
Roel De Nijs
Sheriff
Posts: 10593
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Michael

I changed this line of code in my jsp:


into:


and it's working like a charm.

Thanks for your input. i appreciate it a lot

It's solved so it calls for celebration

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic