You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ne...@levonet.sk on 2005/12/14 13:45:13 UTC

chinese characters and bean tags

I have problem to show chinese characters stored in MySQL database with
use of struts bean tag. Data is read out using Hibernate. When I call
myHibernateObject.getMyProperty() method - everything works fine. But
using <bean:write name="myHibernateObject" property="myProperty"/> does
show text in this notation: &#xxxx &#xxxx. Same problem occurres when I
use this bean in struts form with <html:text name="myHibernateObject"
property="myProperty"/>

Encoding of database is set up properly to gb2312. JSP page uses UTF-8
encoding. How can I set character encoding for struts bean tag ? Or where
is the problem ?

Thanks a lot for your help.
Milan




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts Menu Vs Struts Layout

Posted by Agnisys <ag...@yahoo.com>.
Hi Frank,
  I did look at JWP but got intimidated by the Javadocs. I thought I would get documentation about
the Tags I can use, but instead I found Java classes, and with no signpost for where to begin.
  You have suggested to look at the sample application, which I'll do.

Thanks,
Anupam.


--- "Frank W. Zammetti" <fz...@omnytex.com> wrote:

> I suggest AjaxTags from Java Web Parts:
> 
> http://javawebparts.sourceforge.net
> 
> Hit the javadocs link, then jump to the taglib package, the documentation
> for the package should give you a good idea what its all about, then you
> can grab the JWP distro and try out the sample app for some working
> examples of what is possible.  This is, I believe, the easiest way to add
> AJAX to any Java-based webapp app, be it Struts or otherswise, especially
> for those that don't want to touch Javascript at all.  Yes, I wrote it :)
> 
> If you want to get a feel for doing naked AJAX (i.e., just plain
> Javascript) within a Struts app specifically, I suggest:
> 
> http://struts.sourceforge.net
> 
> Check out the AjaxChat application (yes I wrote that too!).  You already
> said you don't want to write all the Javascript though, so that migth be
> of less interest than AjaxTags may be.
> 
> I also wrote an introductory article to AJAX:
> 
> http://www.omnytex.com/articles
> 
> It deals with Struts as well, but to a lesser extent.  Again though, you
> would do the coding yourself, so might not be what you want anyway.
> 
> Feel free to fire any questions at me if you decided to use AJAX, in
> whatever way.
> 
> -- 
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM: fzammetti
> Yahoo: fzammetti
> MSN: fzammetti@hotmail.com
> 
> On Mon, December 19, 2005 10:27 am, Agnisys said:
> > Hi,
> >   I did spend much time on OpenLazlo but gave it up because of lack of
> > appropriate constructs for
> > dynamic GUI design and lack of proper support.
> >   I would love to use Ajax since it is a light-weight solution. But don't
> > want to deal with all
> > the Javascript coding. I wonder what people are using these days to do
> > Ajax development in a
> > struts environment?
> >   I'm trying to find an integrated environment that works within Struts.
> > Although using Struts is
> > also not a requirement.
> >   I will look at SiteMesh.
> >
> > Thanks,
> > Anupam.
> >
> > --- Yves Sy <yv...@gmail.com> wrote:
> >
> >> Another option would be SiteMesh.
> >>
> >> If you like working on the fringes of technology though, I recommend
> >> AJAX or
> >> OpenLaszlo...
> >>
> >> Br,
> >> -Yves-
> >>
> >> On 12/18/05, Agnisys <ag...@yahoo.com> wrote:
> >> >
> >> > Hi,
> >> >   I need to create an application with lots of Dynamic GUI features
> >> (like
> >> > dynamic number of
> >> > Panes). Which one is more suitable for the job: Struts Menu or Struts
> >> > Layout?
> >> >   Or is there a more appropriate 3rd option?
> >> >
> >> > Thanks for any pointers.
> >> > Anupam.
> >> >
> >> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts Menu Vs Struts Layout

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
I suggest AjaxTags from Java Web Parts:

http://javawebparts.sourceforge.net

Hit the javadocs link, then jump to the taglib package, the documentation
for the package should give you a good idea what its all about, then you
can grab the JWP distro and try out the sample app for some working
examples of what is possible.  This is, I believe, the easiest way to add
AJAX to any Java-based webapp app, be it Struts or otherswise, especially
for those that don't want to touch Javascript at all.  Yes, I wrote it :)

If you want to get a feel for doing naked AJAX (i.e., just plain
Javascript) within a Struts app specifically, I suggest:

http://struts.sourceforge.net

Check out the AjaxChat application (yes I wrote that too!).  You already
said you don't want to write all the Javascript though, so that migth be
of less interest than AjaxTags may be.

I also wrote an introductory article to AJAX:

http://www.omnytex.com/articles

It deals with Struts as well, but to a lesser extent.  Again though, you
would do the coding yourself, so might not be what you want anyway.

Feel free to fire any questions at me if you decided to use AJAX, in
whatever way.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: fzammetti@hotmail.com

On Mon, December 19, 2005 10:27 am, Agnisys said:
> Hi,
>   I did spend much time on OpenLazlo but gave it up because of lack of
> appropriate constructs for
> dynamic GUI design and lack of proper support.
>   I would love to use Ajax since it is a light-weight solution. But don't
> want to deal with all
> the Javascript coding. I wonder what people are using these days to do
> Ajax development in a
> struts environment?
>   I'm trying to find an integrated environment that works within Struts.
> Although using Struts is
> also not a requirement.
>   I will look at SiteMesh.
>
> Thanks,
> Anupam.
>
> --- Yves Sy <yv...@gmail.com> wrote:
>
>> Another option would be SiteMesh.
>>
>> If you like working on the fringes of technology though, I recommend
>> AJAX or
>> OpenLaszlo...
>>
>> Br,
>> -Yves-
>>
>> On 12/18/05, Agnisys <ag...@yahoo.com> wrote:
>> >
>> > Hi,
>> >   I need to create an application with lots of Dynamic GUI features
>> (like
>> > dynamic number of
>> > Panes). Which one is more suitable for the job: Struts Menu or Struts
>> > Layout?
>> >   Or is there a more appropriate 3rd option?
>> >
>> > Thanks for any pointers.
>> > Anupam.
>> >
>> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts Menu Vs Struts Layout

Posted by Agnisys <ag...@yahoo.com>.
Hi,
  I did spend much time on OpenLazlo but gave it up because of lack of appropriate constructs for
dynamic GUI design and lack of proper support. 
  I would love to use Ajax since it is a light-weight solution. But don't want to deal with all
the Javascript coding. I wonder what people are using these days to do Ajax development in a
struts environment?
  I'm trying to find an integrated environment that works within Struts. Although using Struts is
also not a requirement.
  I will look at SiteMesh.

Thanks,
Anupam.

--- Yves Sy <yv...@gmail.com> wrote:

> Another option would be SiteMesh.
> 
> If you like working on the fringes of technology though, I recommend AJAX or
> OpenLaszlo...
> 
> Br,
> -Yves-
> 
> On 12/18/05, Agnisys <ag...@yahoo.com> wrote:
> >
> > Hi,
> >   I need to create an application with lots of Dynamic GUI features (like
> > dynamic number of
> > Panes). Which one is more suitable for the job: Struts Menu or Struts
> > Layout?
> >   Or is there a more appropriate 3rd option?
> >
> > Thanks for any pointers.
> > Anupam.
> >
> >


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts Menu Vs Struts Layout

Posted by Yves Sy <yv...@gmail.com>.
Another option would be SiteMesh.

If you like working on the fringes of technology though, I recommend AJAX or
OpenLaszlo...

Br,
-Yves-

On 12/18/05, Agnisys <ag...@yahoo.com> wrote:
>
> Hi,
>   I need to create an application with lots of Dynamic GUI features (like
> dynamic number of
> Panes). Which one is more suitable for the job: Struts Menu or Struts
> Layout?
>   Or is there a more appropriate 3rd option?
>
> Thanks for any pointers.
> Anupam.
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


--
A bus station is where a bus stops. A train station is where a train stops.
On my desk I have a work station...

Struts Menu Vs Struts Layout

Posted by Agnisys <ag...@yahoo.com>.
Hi,
  I need to create an application with lots of Dynamic GUI features (like dynamic number of
Panes). Which one is more suitable for the job: Struts Menu or Struts Layout?
  Or is there a more appropriate 3rd option?

Thanks for any pointers.
Anupam.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: chinese characters and bean tags

Posted by ne...@levonet.sk.
Hello Jose,

exactly! This solves my problem. Fortunately I do not have so many chinese
fields in my allplication. So it should not be complicated to close all
possible security holes.

Thanks a lot,
Milan

> Have you tried using <bean:write name="chinatext" property="text"
> filter="false"/>?
>
> filter="false" means the tag will not "escape" HTML characteres... the
> default value is true IIRC. Maybe during that filtering it is also
> escaping
> non-ASCII characters? (wild guess here, since the last Struts version I
> used
> was 1.1)
>
> The problem with filter="false" is that is opens your app to all sorts of
> cross-site scripting security holes... so you would have to guarantee the
> user cannot enter some javascript code that will end up being printed by
> this tag later on... =(
>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: chinese characters and bean tags

Posted by Jose Ventura <jo...@gmail.com>.
Have you tried using <bean:write name="chinatext" property="text"
filter="false"/>?

filter="false" means the tag will not "escape" HTML characteres... the
default value is true IIRC. Maybe during that filtering it is also escaping
non-ASCII characters? (wild guess here, since the last Struts version I used
was 1.1)

The problem with filter="false" is that is opens your app to all sorts of
cross-site scripting security holes... so you would have to guarantee the
user cannot enter some javascript code that will end up being printed by
this tag later on... =(

Re: chinese characters and bean tags

Posted by Rahul Akolkar <ra...@gmail.com>.
On 12/16/05, news@levonet.sk <ne...@levonet.sk> wrote:
> > news@levonet.sk wrote:
<snip/>
> >>> make sure that you have the UFT-8 charsett declared in the content type
> >>> of the response -- e.g. with <%@ page contentType="text/html;
> >>> charset=UTF-8"%> and/or HTML META-tags.
> >>>
> >>> L.
>
> So, here the most important part of my JSP code:
>
> <head>
> <html:base/>
> <title>test</title>
> <META http-equiv="Content-Type" content="text/html;charset=UTF-8">
> </head>
>
<snap/>

Do you have the JSP page directive set as suggested above? The HTML
<META> tags are best considered to be "hints".

-Rahul


> <%
>
> /*
> * +++ TEST CASE 1 +++
> */
>
> // business logic for obtaining all hibernated objects
> BOGeneric bo = new BOGeneric();
> List l = bo.find("ChinaText", new Criterion[] {}, new Order[] {});
> pageContext.setAttribute("names", l);
>
> // runs it throung and prints out all the texts
> for (Iterator i=l.iterator(); i.hasNext();) {
>        out.println(((ChinaText)i.next()).getText() + " : ");
> }
> %>
>
> <!--
> +++ TEST CASE 2 +++
> now the same using struts
> -->
> <logic:iterate id="chinatext" collection="<%=l%>">
>        <bean:write name="chinatext" property="text"/> -
> </logic:iterate>
>
> In the first test case I get correct encoded chinese texts. In the second
> one I get only &#xxxx strings.
>
<snip/>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: chinese characters and bean tags

Posted by ne...@levonet.sk.
> news@levonet.sk wrote:
>>>> I have problem to show chinese characters stored in MySQL database
>>>> with
>>>> use of struts bean tag. Data is read out using Hibernate. When I call
>>>> myHibernateObject.getMyProperty() method - everything works fine. But
>>>> using <bean:write name="myHibernateObject" property="myProperty"/>
>>>> does
>>>> show text in this notation: &#xxxx &#xxxx. Same problem occurres when
>>>> I
>>>> use this bean in struts form with <html:text name="myHibernateObject"
>>>> property="myProperty"/>
>>>>
>>>> Encoding of database is set up properly to gb2312. JSP page uses UTF-8
>>>> encoding. How can I set character encoding for struts bean tag ? Or
>>>> where
>>>> is the problem ?
>>> How are you verifying that what you get back from the database is
>>> correct? If anywhere in the data retrieval pipeline is using the wrong
>>> encoding, you'll get corrupted data. Try hard-coding an output value to
>>> see if you are able to display that correctly.
>>>
>>> If that fails, it must be something in the way you've written your JSP;
>>> make sure that you have the UFT-8 charsett declared in the content type
>>> of the response -- e.g. with <%@ page contentType="text/html;
>>> charset=UTF-8"%> and/or HTML META-tags.
>>>
>>> L.

So, here the most important part of my JSP code:

<head>
<html:base/>
<title>test</title>
<META http-equiv="Content-Type" content="text/html;charset=UTF-8">
</head>

<%

/*
* +++ TEST CASE 1 +++
*/

// business logic for obtaining all hibernated objects
BOGeneric bo = new BOGeneric();
List l = bo.find("ChinaText", new Criterion[] {}, new Order[] {});
pageContext.setAttribute("names", l);

// runs it throung and prints out all the texts
for (Iterator i=l.iterator(); i.hasNext();) {
	out.println(((ChinaText)i.next()).getText() + " : ");
}
%>

<!--
+++ TEST CASE 2 +++
now the same using struts
-->
<logic:iterate id="chinatext" collection="<%=l%>">
	<bean:write name="chinatext" property="text"/> -
</logic:iterate>

In the first test case I get correct encoded chinese texts. In the second
one I get only &#xxxx strings.

>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>
>> I have verified it with <%=myObject.getProperty()%> in the JSP. In this
>> case I got chinese string with right encoding. But using <bean:write
>> name="myObject" property="property"/> produces string in this wrong
>> encoding format: &#xxxx. Charset of the JSP page is set to UTF-8.
>
> In that case I'm not sure what's going on... Can you post a short JSP
> fragment that demonstrates the problem?
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: chinese characters and bean tags

Posted by Laurie Harper <la...@holoweb.net>.
news@levonet.sk wrote:
>>> I have problem to show chinese characters stored in MySQL database with
>>> use of struts bean tag. Data is read out using Hibernate. When I call
>>> myHibernateObject.getMyProperty() method - everything works fine. But
>>> using <bean:write name="myHibernateObject" property="myProperty"/> does
>>> show text in this notation: &#xxxx &#xxxx. Same problem occurres when I
>>> use this bean in struts form with <html:text name="myHibernateObject"
>>> property="myProperty"/>
>>>
>>> Encoding of database is set up properly to gb2312. JSP page uses UTF-8
>>> encoding. How can I set character encoding for struts bean tag ? Or
>>> where
>>> is the problem ?
>> How are you verifying that what you get back from the database is
>> correct? If anywhere in the data retrieval pipeline is using the wrong
>> encoding, you'll get corrupted data. Try hard-coding an output value to
>> see if you are able to display that correctly.
>>
>> If that fails, it must be something in the way you've written your JSP;
>> make sure that you have the UFT-8 charsett declared in the content type
>> of the response -- e.g. with <%@ page contentType="text/html;
>> charset=UTF-8"%> and/or HTML META-tags.
>>
>> L.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
> 
> I have verified it with <%=myObject.getProperty()%> in the JSP. In this
> case I got chinese string with right encoding. But using <bean:write
> name="myObject" property="property"/> produces string in this wrong
> encoding format: &#xxxx. Charset of the JSP page is set to UTF-8.

In that case I'm not sure what's going on... Can you post a short JSP 
fragment that demonstrates the problem?

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: chinese characters and bean tags

Posted by ne...@levonet.sk.
>> I have problem to show chinese characters stored in MySQL database with
>> use of struts bean tag. Data is read out using Hibernate. When I call
>> myHibernateObject.getMyProperty() method - everything works fine. But
>> using <bean:write name="myHibernateObject" property="myProperty"/> does
>> show text in this notation: &#xxxx &#xxxx. Same problem occurres when I
>> use this bean in struts form with <html:text name="myHibernateObject"
>> property="myProperty"/>
>>
>> Encoding of database is set up properly to gb2312. JSP page uses UTF-8
>> encoding. How can I set character encoding for struts bean tag ? Or
>> where
>> is the problem ?
>
> How are you verifying that what you get back from the database is
> correct? If anywhere in the data retrieval pipeline is using the wrong
> encoding, you'll get corrupted data. Try hard-coding an output value to
> see if you are able to display that correctly.
>
> If that fails, it must be something in the way you've written your JSP;
> make sure that you have the UFT-8 charsett declared in the content type
> of the response -- e.g. with <%@ page contentType="text/html;
> charset=UTF-8"%> and/or HTML META-tags.
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>

I have verified it with <%=myObject.getProperty()%> in the JSP. In this
case I got chinese string with right encoding. But using <bean:write
name="myObject" property="property"/> produces string in this wrong
encoding format: &#xxxx. Charset of the JSP page is set to UTF-8.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: chinese characters and bean tags

Posted by Laurie Harper <la...@holoweb.net>.
news@levonet.sk wrote:
> I have problem to show chinese characters stored in MySQL database with
> use of struts bean tag. Data is read out using Hibernate. When I call
> myHibernateObject.getMyProperty() method - everything works fine. But
> using <bean:write name="myHibernateObject" property="myProperty"/> does
> show text in this notation: &#xxxx &#xxxx. Same problem occurres when I
> use this bean in struts form with <html:text name="myHibernateObject"
> property="myProperty"/>
> 
> Encoding of database is set up properly to gb2312. JSP page uses UTF-8
> encoding. How can I set character encoding for struts bean tag ? Or where
> is the problem ?

How are you verifying that what you get back from the database is 
correct? If anywhere in the data retrieval pipeline is using the wrong 
encoding, you'll get corrupted data. Try hard-coding an output value to 
see if you are able to display that correctly.

If that fails, it must be something in the way you've written your JSP; 
make sure that you have the UFT-8 charsett declared in the content type 
of the response -- e.g. with <%@ page contentType="text/html; 
charset=UTF-8"%> and/or HTML META-tags.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org