aspose file tools*
The moose likes Struts and the fly likes Recipe 4 strange characters ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Recipe 4 strange characters ?" Watch "Recipe 4 strange characters ?" New topic
Author

Recipe 4 strange characters ?

Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5278
    
  13

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.


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Michael Arndt
Greenhorn

Joined: Feb 25, 2003
Posts: 21
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
Bartender

Joined: Jul 19, 2004
Posts: 5278
    
  13

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

Joined: Oct 16, 2002
Posts: 16
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

Joined: Feb 25, 2003
Posts: 21
@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
Bartender

Joined: Jul 19, 2004
Posts: 5278
    
  13

@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
Bartender

Joined: Jul 19, 2004
Posts: 5278
    
  13

@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

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Recipe 4 strange characters ?