473,657 Members | 2,661 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JSP Java truncates string at the first non-english character

Hi

I have a problem with JSP on websphere 5. When I try save information
with swedish or danish ÅÄÖ characters, the string is cut where the
first of these characters occurs. The JDK used is 1.3.1

I've tried:

String CUNM = request.getPara meter("CUNM").t rim();
CUNM = URLDecoder.deco de(CUNM,"UTF-8");

and

String CUNM = new String(request. getParameter("C UNM").getBytes( "windows-1252"));

and

request.setChar acterEncoding(" UTF-8"); before I access any parameters,
which returns a servlet error.

Does anybody have a answer, or ideas on this one.

/Erkki
Jul 17 '05 #1
4 11638
sc************* ***@hotmail.com (knocker) wrote in message news:<73******* *************** ****@posting.go ogle.com>...
Hi

I have a problem with JSP on websphere 5. When I try save information
with swedish or danish ÅÄÖ characters, the string is cut where the
first of these characters occurs. The JDK used is 1.3.1

I've tried:

String CUNM = request.getPara meter("CUNM").t rim();
CUNM = URLDecoder.deco de(CUNM,"UTF-8");

and

String CUNM = new String(request. getParameter("C UNM").getBytes( "windows-1252"));

and

request.setChar acterEncoding(" UTF-8"); before I access any parameters,
which returns a servlet error.

Does anybody have a answer, or ideas on this one.

/Erkki
String CUNM = request.getPara meter("CUNM").t rim(); Don't do trim(). The behavior is unpredictable.
CUNM = URLDecoder.deco de(CUNM,"UTF-8"); Don't do this. Already URLdecoded.
String CUNM = new String(request. getParameter("C UNM").getBytes( "windows-1252")); Oh no. It's too late. Don't do this.
request.setChar acterEncoding(" UTF-8"); before I access any parameters,
which returns a servlet error.

What error? windows-1252 and UTF-8, aren't they contradicting? Or,
are they same?

In you JSP:
page pageEncoding ... Your JSP file's encoding e.g ISO-DANISH-PASTRY
page contentType charset ... UTF-8 will do, or (i don't know :)
<% request.setChar acterEncoding(" ... "); %> ... Same as above.

In your servlet:
response.setCon tentType("text/html; charset=....");
//ISO-DANISH-PASTRY
request.setChar acterEncoding(" ..."); //UTF-8 will do
out.println
("<META http-equiv=Content-Type content=\"text/html;
charset=....\"> "); //ISO-DANISH-PASTRY

(Sorry, I don't know correct ISO number for Danish.)
Jul 17 '05 #2
HG******@nifty. ne.jp (hiwa) wrote in message news:<68******* *************** ****@posting.go ogle.com>...
sc************* ***@hotmail.com (knocker) wrote in message news:<73******* *************** ****@posting.go ogle.com>...
Hi

I have a problem with JSP on websphere 5. When I try save information
with swedish or danish ÅÄÖ characters, the string is cut where the
first of these characters occurs. The JDK used is 1.3.1

I've tried:

String CUNM = request.getPara meter("CUNM").t rim();
CUNM = URLDecoder.deco de(CUNM,"UTF-8");

and

String CUNM = new String(request. getParameter("C UNM").getBytes( "windows-1252"));

and

request.setChar acterEncoding(" UTF-8"); before I access any parameters,
which returns a servlet error.

Does anybody have a answer, or ideas on this one.

/Erkki
String CUNM = request.getPara meter("CUNM").t rim(); Don't do trim(). The behavior is unpredictable.


What should I do instead?
CUNM = URLDecoder.deco de(CUNM,"UTF-8"); Don't do this. Already URLdecoded.
String CUNM = new String(request. getParameter("C UNM").getBytes( "windows-1252"));

Oh no. It's too late. Don't do this.


Already noticed that :-)

Problem is that if I do a length check on the parameter it returns 2
if the string is "tråäö"
request.setChar acterEncoding(" UTF-8"); before I access any parameters,
which returns a servlet error. What error? windows-1252 and UTF-8, aren't they contradicting? Or,
are they same?

In you JSP:
page pageEncoding ... Your JSP file's encoding e.g ISO-DANISH-PASTRY
page contentType charset ... UTF-8 will do, or (i don't know :)
<% request.setChar acterEncoding(" ... "); %> ... Same as above.


did : <%@ page language="java" pageEncoding="W INDOWS-1251" %>
can't do "page pageEncoding" returns a
JSPG0063E: Page directive: Invalid attribute, pageEncoding

tried with charset also, but it said "cannot read file"

In your servlet:
response.setCon tentType("text/html; charset=....");


It won't let me do that. Returns an error...

charset is "windows-1252" and it shows åäö if do put the characters in
a java string like this:

String testStr = "ÅÄÖ";

And show it if I do:

<%=testStr%>

But the request object cuts the bl---y string if get or post parameter
contains ÅÄÖ.

I've done escape and URLDecode, but that don't work either...

/Erkki
Jul 17 '05 #3
Let me repeat:

--instructions--------------------------------------------------------

On you JSP page, required entries are:
<%@ page
contentType="te xt/html; charset=UTF-8"
pageEncoding="y our-local-platform-encoding"
....
....
%>
<% request.setChar acterEncoding(" UTF-8"); %>

On your servlet:
response.setCon tentType("text/html;
charset=client-handlable-encoding");
request.setChar acterEncoding(" UTF-8");
out.println
("<META http-equiv=Content-Type content=\"text/html;
charset=client-handlable-encoding\">");

-----------------------------------------------------------------------
Don't do trim(). The behavior is unpredictable. What should I do instead?

Love it as is.
JSPG0063E: Page directive: Invalid attribute, pageEncoding Your server doesn't support JSP 1.2, or, simply broken.
tried with charset also, but it said "cannot read file" File? What file?
response.setCon tentType("text/html; charset=....");

It won't let me do that. Returns an error...

Your server is broken, or, charset value is invalid or having typo.
I've done escape and URLDecode, but that don't work either...

You should not need it.

Appendix:
Check your Java system properties, especially:
user.country=
file.encoding=
and
user.language=

Do they match your local encoding?
Jul 17 '05 #4
HG******@nifty. ne.jp (hiwa) wrote in message news:<68******* *************** ****@posting.go ogle.com>...

First of all let me thank you for your time and effort. This is one
thing that really make loose all the marbles...
Let me repeat:

--instructions--------------------------------------------------------

On you JSP page, required entries are:
<%@ page
contentType="te xt/html; charset=UTF-8"
pageEncoding="y our-local-platform-encoding"
...
...
%>
<% request.setChar acterEncoding(" UTF-8"); %>

On your servlet:
response.setCon tentType("text/html;
charset=client-handlable-encoding");
request.setChar acterEncoding(" UTF-8");
out.println
("<META http-equiv=Content-Type content=\"text/html;
charset=client-handlable-encoding\">");

-----------------------------------------------------------------------
I'll try that. But, for give me for saying so, I don't have much hope
since pageEncodning returns the illegal attribute error.
Don't do trim(). The behavior is unpredictable. What should I do instead?

Love it as is.


I'm trying, but it's so hard...;=). No seriously, I'll drop the
trim()...
JSPG0063E: Page directive: Invalid attribute, pageEncoding Your server doesn't support JSP 1.2, or, simply broken.


the former then...
tried with charset also, but it said "cannot read file" File? What file?


The jsp file...
When I set page attribute charset only, it says it can't read the
file. I'll post my code as soon as the holiday is over.
response.setCon tentType("text/html; charset=...."); It won't let me do that. Returns an error...

Your server is broken, or, charset value is invalid or having typo.


"windows-1252"...
I've done escape and URLDecode, but that don't work either... You should not need it.


I know.

Appendix:
Check your Java system properties, especially:
user.country=
file.encoding=
and
user.language=

Do they match your local encoding?


They should match Western Europe, but I'll recheck.
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4619
by: Min-Koo Seo | last post by:
Hi. I have a java stored procedure whose spec is as follows: CREATE OR REPLACE FUNCTION DECODE_SEQUENCE(SEQUENCE VARCHAR2) RETURN VARCHAR2 DETERMINISTIC AS LANGUAGE JAVA NAME 'kr.ac.dke.protein.compression.SequenceCompressor.decode(java.lang.String) return java.lang.String';
10
3610
by: Marcin Kalicinski | last post by:
Why string literals are regarded as char * not as const char *? (1) void f(char *); (2) void f(const char *); f("foo") will call version (1) of function f. I understand that the exact type of literal "foo" is char, which by means of standard conversion becomes char *. Still, there's something going wrong here, because this allows modification of "foo", which in my opinion should
1
1961
by: Kim | last post by:
Hello, I am selecting data from a text file with the following statement: "INSERT INTO SELECT * FROM " & sSource & " IN '' " & _ "'text;Database=" & sPath & ";FMT=Delimited;HDR=No' " & _ "WHERE = '01'" It works correctly EXCEPT when the record length is more than 254, it truncates the record. Is there a way to expand the length of string
1
1385
by: vbdotnetmania | last post by:
Hi, I'm trying to port java code to c#, I am not too familiar with either so forgive me for what might be a stupid question, I wish to use the java string type rather than the c# one, when I try to declare the type as java.lang.string I am not allowed, is there a way I can use the java string type rather than the c# native string type. Any help would be great. Thanks, barry.
2
3451
by: Madhusudhanan Chandrasekaran | last post by:
Hi all: When I try to convert a float variable into string via repr() or str() function, i get the value as is, i.e '0.1e-7' in IEEE 754 format. Instead how can force the created string to represent the floating point in non-scientific fashion (non IEEE 754 format)? i.e something like 0.000000001 Thanks in advance for your help.
1
1486
by: Bob Rock | last post by:
Hello, using the WriteLine method of the Trace class I noticed that strings containing null characters (i.e. \0) get truncated in the output window at the first null char and anything that follows simply gets lost. I'm using ..NET 1.1 (have not tested with 2.0). Try the following to see what I mean: Trace.WriteLine("xxxx\0\0xxxx");
1
11595
by: rainman33 | last post by:
I am getting this error message in the program I'm working on (line 150), and am wondering what it means? This is an exercise for a college class; just want to declare that; this is not my own work. Here is the program that I am working with: // This application inputs and outputs account information. import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.*;
5
5519
by: Mike | last post by:
I use MS SQL EXPRESS DB VS 2005, c# Win Application I have problem "The string is non-numeric" with formula CDbl({pr_DajPonudu;1.KolicinskiPopust})/100 * {@NajamProstora}
5
3481
by: creative1 | last post by:
hi, I am new at writing JSP and Servlets. When I compile my serverlet I get follwoing error cannot find mymbol method parseDate(java.lang.String) I have follwoing code: Code: ( text ) package admin; import java.lang.Object.*;
1
3135
by: ahmee | last post by:
this my program code these are my errors below please help me out....guys operater % cannot be applied to java.lang.String.int operater / cannot be applied to java.lang.String.int operater + cannot be applied to <any>,int import javax.swing.*; class demo {
0
8837
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8512
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8612
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7347
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6175
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2739
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.