You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Paul Pogonyshev <p....@anakreon.net> on 2006/11/15 15:28:38 UTC

charset problem

Hi,

My page starts with "<%@ page contentType="text/html; charset=utf-8"...",
but apparently charset is not taken into account.  I.e. when a page is
rendered as JSP (with all JSF-specific contents removed, of course), non-
ASCII characters are written in UTF-8 encoding, as expected.  However, if
the page is rendered as JSF, non-ASCII characters from Java code are
written as HTML-entities, i.e. the code doesn't know it should write in
UTF-8 charset.

Is there a way to fix this problem?  How do I specify charset for JSF?

Paul

Re: help : url problem

Posted by Gerald Müllan <bi...@gmail.com>.
Hi,

if you need a kind of automatically page-refresh you can use the
ppr-sandbox approach. With this component only parts of a page are
re-rendered after a given timeout.

But it is currently only in sandbox stadium, so it may have some issues.

Have a look at our examples page:

http://example.irian.at/example-sandbox-20061120/pprPanelGroupPeriodicalUpdate.jsf

cheers,

Gerald

On 11/20/06, Mr Arvind Pandey <ar...@yahoo.co.in> wrote:
> Hi all,
>
>    Using tomahawk tiles with JSF application, always
> shows the previous URL in the browser. As per the
> requirement of my application, I need to refresh the
> current page after a time-interval.
>    But the browaser always shows the previous URL,
> hence once the time-interval is hit, it refreshes the
> previous page because URL in the browser is previous
> one.
>   To refresh the current page I m using :
>     <meta http-equiv="refresh" content="60">. It means
> the current page will be refreshed after 60 seconds.
>
>
>     Please help, I have been stuck with this sice
> three days.
>
> Thanks and regards....
> Arvind
>
>
>
>
>
> __________________________________________________________
> Yahoo! India Answers: Share what you know. Learn something new
> http://in.answers.yahoo.com/
>


-- 
http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Re: charset problem

Posted by Paul Pogonyshev <p....@anakreon.net>.
Randahl Fink Isaksen wrote:
> If you are using facelets this character entity problem will
> not go away until the next release of facelets. I have written
> another post earlier about this called   
>  
> "Its a bug: Facelets+MyFaces cannot serve UTF-8 and here is why!"
>  
> Randahl

Apparently I don't...

Paul

Re: charset problem

Posted by Paul Pogonyshev <p....@anakreon.net>.
Daniel Young wrote:
> You may find you need a CharsetFilter:
> 
> public void doFilter(final ServletRequest request, final ServletResponse
> response, final FilterChain chain) throws IOException, ServletException {
>    request.setCharacterEncoding(encoding);
>    chain.doFilter(request, response);
> }
> 
> I tried using the <locale-encoding-mapping-list> in web.xml but really had
> no joy until I added the CharsetFilter.
> 
> Ref: http://wiki.apache.org/tomcat/Tomcat/UTF-8

Unfortunately, this doesn't help :(  Actually, I written a charset
filter before (with the same code)...

Does the simple page I attached work as expected (produces UTF-8
characters, not entities) for you?

Paul

RE: charset problem

Posted by Daniel Young <dy...@synyati.com.au>.
Hi Paul,

You may find you need a CharsetFilter:

public void doFilter(final ServletRequest request, final ServletResponse
response, final FilterChain chain) throws IOException, ServletException {
   request.setCharacterEncoding(encoding);
   chain.doFilter(request, response);
}

I tried using the <locale-encoding-mapping-list> in web.xml but really had
no joy until I added the CharsetFilter.

Ref: http://wiki.apache.org/tomcat/Tomcat/UTF-8



-----Original Message-----
From: Paul Pogonyshev [mailto:p.pogonyshev@anakreon.net] 
Sent: Saturday, 18 November 2006 2:36 AM
To: users@myfaces.apache.org
Cc: Jeff Bischoff
Subject: Re: charset problem

I wrote:
> Jeff Bischoff wrote:
> > I haven't had any trouble using UTF-8 so far. Can you confirm that you 
> > have the following in your pages:
> > 
> > <%@ page contentType="text/html; charset=utf-8" language="java" %>
> > ...
> > <head>
> >    ...
> >    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
> > </head>
> >
> > I'm pretty sure you need both.
> 
> Yes, I do have both.
> 
> > Can you be more specific about your problem? What do you mean by 
> > "characters from Java code"?
> 
> Actually, those include both characters from Java code and simply coded
> in in the page, e.g.
> 
> 	абвгд
> 	<%= "абвгд" %>
> 
> both produce HTML-entities, even though Cyrillic letters are encodable
> in UTF-8.  This is not a problem in HTML parts (except for increased
> page size), but is not appropriate in JavaScript.

Here is a simple page to check this (but I admit this might be a local
problem or JSP/JSF combination problem):

<%@ page
    contentType="text/html; charset=UTF-8"
    language="java"
%>
<%@ include file="/base/taglibInclude.jsp" %>
<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
  абвгд
  <%= "абвгд" %>
<f:view>
  абвгд
  <%= "абвгд" %>
</f:view>
  абвгд
  <%= "абвгд" %>
</body>
</html>



Re: help : url problem

Posted by Simon Kitching <si...@rhe.co.nz>.
Mr Arvind Pandey wrote:
> Hi all,
>
>    Using tomahawk tiles with JSF application, always
> shows the previous URL in the browser. As per the
> requirement of my application, I need to refresh the
> current page after a time-interval. 
>    But the browaser always shows the previous URL,
> hence once the time-interval is hit, it refreshes the
> previous page because URL in the browser is previous
> one.
>   To refresh the current page I m using :
>     <meta http-equiv="refresh" content="60">. It means
> the current page will be refreshed after 60 seconds.
>   

The general solution for the problem "url points to previous page" is to 
use the "redirect" attribute in the navigation rule. When this is used, 
rather than page A simply doing an internal forward to page B, an HTTP 
redirect header is sent back to the browser by page A, causing the 
browser to fetch page B directly. The result is that the browser then 
(correctly) has page B as its current url. There are disadvantages to 
using the redirect attribute, though: you can't pass data from A's 
backing bean to B's backing bean via request-scope properties for 
example, and performance takes a hit due to the round-trip.

Hope this helps.

Regards,

Simon



Re: help : url problem

Posted by Jonathan Harley <jo...@parkplatz.net>.
Mr Arvind Pandey wrote:
>    Using tomahawk tiles with JSF application, always
> shows the previous URL in the browser. As per the
> requirement of my application, I need to refresh the
> current page after a time-interval. 
>    But the browaser always shows the previous URL,
> hence once the time-interval is hit, it refreshes the
> previous page because URL in the browser is previous
> one.
>   To refresh the current page I m using :
>     <meta http-equiv="refresh" content="60">. It means
> the current page will be refreshed after 60 seconds.

You could always try ajax4jsf; it's very easy to add to a JSF
application. It has a tag called a4j:poll which can periodically
refresh a section of a page. ajax4jsf knows what JSF view it's
being used in, which means it doesn't matter that browser
doesn't know the current page URL.


-- 
.....................................................................
           Dr Jonathan Harley   .
                                .   Email: jon@parkplatz.net
            Zac Parkplatz Ltd   .   Office Telephone: 024 7633 1375
            www.parkplatz.net   .   Mobile: 079 4116 0423

help : url problem

Posted by Mr Arvind Pandey <ar...@yahoo.co.in>.
Hi all,

   Using tomahawk tiles with JSF application, always
shows the previous URL in the browser. As per the
requirement of my application, I need to refresh the
current page after a time-interval. 
   But the browaser always shows the previous URL,
hence once the time-interval is hit, it refreshes the
previous page because URL in the browser is previous
one.
  To refresh the current page I m using :
    <meta http-equiv="refresh" content="60">. It means
the current page will be refreshed after 60 seconds.
 

    Please help, I have been stuck with this sice
three days.

Thanks and regards....
Arvind




		
__________________________________________________________
Yahoo! India Answers: Share what you know. Learn something new
http://in.answers.yahoo.com/

Re: charset problem

Posted by Paul Pogonyshev <p....@anakreon.net>.
I wrote:
> Jeff Bischoff wrote:
> > I haven't had any trouble using UTF-8 so far. Can you confirm that you 
> > have the following in your pages:
> > 
> > <%@ page contentType="text/html; charset=utf-8" language="java" %>
> > ...
> > <head>
> >    ...
> >    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
> > </head>
> >
> > I'm pretty sure you need both.
> 
> Yes, I do have both.
> 
> > Can you be more specific about your problem? What do you mean by 
> > "characters from Java code"?
> 
> Actually, those include both characters from Java code and simply coded
> in in the page, e.g.
> 
> 	абвгд
> 	<%= "абвгд" %>
> 
> both produce HTML-entities, even though Cyrillic letters are encodable
> in UTF-8.  This is not a problem in HTML parts (except for increased
> page size), but is not appropriate in JavaScript.

Here is a simple page to check this (but I admit this might be a local
problem or JSP/JSF combination problem):

<%@ page
    contentType="text/html; charset=UTF-8"
    language="java"
%>
<%@ include file="/base/taglibInclude.jsp" %>
<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
  абвгд
  <%= "абвгд" %>
<f:view>
  абвгд
  <%= "абвгд" %>
</f:view>
  абвгд
  <%= "абвгд" %>
</body>
</html>

Re: charset problem

Posted by Paul Pogonyshev <p....@anakreon.net>.
Jeff Bischoff wrote:
> I haven't had any trouble using UTF-8 so far. Can you confirm that you 
> have the following in your pages:
> 
> <%@ page contentType="text/html; charset=utf-8" language="java" %>
> ...
> <head>
>    ...
>    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
> </head>
>
> I'm pretty sure you need both.

Yes, I do have both.

> Can you be more specific about your problem? What do you mean by 
> "characters from Java code"?

Actually, those include both characters from Java code and simply coded
in in the page, e.g.

	абвгд
	<%= "абвгд" %>

both produce HTML-entities, even though Cyrillic letters are encodable
in UTF-8.  This is not a problem in HTML parts (except for increased
page size), but is not appropriate in JavaScript.

Note that the site is in JSP and I only add JSF on top of that, at the
request of the client.  It is probably a hack, but works fine except
for the charset problem...

Paul

Re: charset problem

Posted by Jeff Bischoff <jb...@klkurz.com>.
Paul,

I haven't had any trouble using UTF-8 so far. Can you confirm that you 
have the following in your pages:

<%@ page contentType="text/html; charset=utf-8" language="java" %>
...
<head>
   ...
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>

I'm pretty sure you need both.

Can you be more specific about your problem? What do you mean by 
"characters from Java code"?

Regards,

Jeff Bischoff
Kenneth L Kurz & Associates, Inc.

Paul Pogonyshev wrote:
> Hi,
> 
> My page starts with "<%@ page contentType="text/html; charset=utf-8"...",
> but apparently charset is not taken into account.  I.e. when a page is
> rendered as JSP (with all JSF-specific contents removed, of course), non-
> ASCII characters are written in UTF-8 encoding, as expected.  However, if
> the page is rendered as JSF, non-ASCII characters from Java code are
> written as HTML-entities, i.e. the code doesn't know it should write in
> UTF-8 charset.
> 
> Is there a way to fix this problem?  How do I specify charset for JSF?
> 
> Paul
> 
> 
>