Thanks Brice and Yoav. fiskars.com is very slick indeed. Brice, your response was very helpful; I verified that that all my files are saved with the proper encoding (some of them were not).
But I’m still having a problem: I have a custom tag that reads a file and writes its content to the JSP’s writer. The file is UTF-8 encoded. I was hoping that setting the page’s encoding to UTF-8 would set the writer’s character encoding to UTF-8, but that is not the case. More specifically, pageContext.getResponse().getCharacterEncoding() always returns 8859. >From looking at the code, I think it’s because the JSP works with instances of ApplicationHttpResponse, which wraps a HttpServletResponse. Because the ApplicationHttpResponse is included, the call to ApplicationHttpResponse.setContentType never makes it to HttpServletResponse.setContentType. The workaround I found was to change the default encoding in org/apache/catalina/util/CharsetMapperDefault.properties and re-jar catalina.jar. So, now the response’s encoding is UTF8, I have my resource as an array of bytes, but I don’t have a method in JSPWriter to write bytes. Therefore, I have to convert them either to chars (which I don’t really want to do), or create a UTF8 string from the bytes array, and write the string to the writer. I’m fairly new to this and I apologize if it all sounds silly, but is there a better way to write UTF8 character to a JSP in a custom tag? Thank you so much, Sophia. --- "Shapira, Yoav" <[EMAIL PROTECTED]> wrote: > > Hi, > That's an excellent response and fiskars.com is a > nice-looking site. > Thanks, > > Yoav Shapira > Millennium Research Informatics > > > >-----Original Message----- > >From: Ruth, Brice [mailto:[EMAIL PROTECTED] > >Sent: Tuesday, July 13, 2004 12:25 PM > >To: Tomcat Users List > >Subject: Re: Problems with Tomcat, Struts/Tiles, > and encoding > > > >I have a Struts/Tiles application running on Tomcat > 4.1.x and Tomcat > 5.x > >with UTF-8 encoding (Polish & Russian character > sets, particularly) - I > >didn't have to do anything special for the response > encoding, only for > >the request encoding. Here's what I put at the top > of my JSPs: > > > ><%@ page contentType="text/html; charset=UTF-8" %> > > > >That seems to do the trick for me. The character > encoding for the page > >is UTF-8 regardless if I'm requesting a JSP > directly, or going through > >an Action. > > > >The entire www.fiskars.com site is Struts/Tiles > driven, you can check > >out http://www.fiskars.com/ru_RU/index.do in > particular to see the RU > >character set being used (in UTF-8 encoding). > > > >Like I said, the only special thing concerns > request encoding ... a > >filter needed to be installed for that. How are you > determining that > the > >encoding being sent the the browser isn't UTF-8? > Garbage characters > >alone won't be a good indication ... in Firefox, I > go to the "View" > menu > >pop-out the "Character Encoding" menu ... make sure > that its set to > >UTF-8. If it is and you're still getting garbage > characters, you may > not > >be saving the JSP files as UTF-8 in your editor. In > Eclipse, for > >instance, you need to specify that the file is > UTF-8 in the file's > >properties (or globally for all files) .. if you > don't, it will look > >like the characters are being inserted correctly, > but when Eclipse > saves > >the file, it converts all the characters to > ISO-8859-1 which will look > >like garbage in the browser, even if the encoding > is set to UTF-8. > > > >Hope some of this helps! > > > >Brice > > > >Susie Derkins wrote: > > > >>Hi list, > >> > >>I'm using Tiles with Catalina (4.1.29 on Linus and > >>Windows). and I'm having problems setting the > >>response's encoding to UTF-8. > >> > >>I added: > >><%@ page contentType="text/html;charset=UTF-8" > >>pageEncoding-"UTF-8" %> > >>to all my JSP pages - tiles and layouts. It is the > >>first line of each page. > >> > >>So now, all my JSPs call > >>ApplicationHttpResponse.setContentType *before* > >>accessing the page's writer. > >> > >>Here is the code for setContentType: > >>public void setContentType(String type) { > >> if (!included) > >> getResponse().setContentType(type); > >>} > >> > >>The problem is that the body of setContentType is > >>never executed because each time a JSP calls it, > >>included is true (I verified by stepping through > the > >>code with a debugger), which means we are inside a > >>RequestDispatcher.include(). My guess is that it's > >>Tiles or Struts that causes the request to be > dispatch > >>via RequestDispatcher.include. > >> > >>I tried to set the response's content type in a > >>filter, but when I check in my custom tags, > >>pageContext.getResponse().pageContext.getResponse() > >>always returns ISO-8859-1, Tomcat's default > encoding. > >> > >>Setting the encoding in a JSP works fine as long > as > >>Struts/Tiles are not involved. > >> > >>Can somebody please shed some light on this? Do > you > >>know of another way of setting the encoding, that > can > >>occur before the JSPs are processed? > >>I want to avoid having to build a custom version > of > >>Tomcat with UTF-8 as the default encoding. > >> > >>Thanks for your time, > >> > >>Sophia. > >> > >>______________________________________________________________________ > >>Post your free ad now! http://personals.yahoo.ca > >> > >>--------------------------------------------------------------------- > >>To unsubscribe, e-mail: > [EMAIL PROTECTED] > >>For additional commands, e-mail: > [EMAIL PROTECTED] > >> > >> > >> > > > >-- > >Brice Ruth, Sr. IT Analyst > >Fiskars Brands Inc > >http://www.fiskarsbrands.com/ > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: > [EMAIL PROTECTED] > >For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > This e-mail, including any attachments, is a > confidential business communication, and may contain > information that is confidential, proprietary and/or > privileged. This e-mail is intended only for the > individual(s) to whom it is addressed, and may not > be saved, copied, printed, disclosed or used by > anyone else. If you are not the(an) intended > recipient, please immediately delete this e-mail > from your computer system and notify the sender. > Thank you. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > ______________________________________________________________________ Post your free ad now! http://personals.yahoo.ca --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]