File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Possible addition to the Servlet FAQ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Possible addition to the Servlet FAQ" Watch "Possible addition to the Servlet FAQ" New topic

Possible addition to the Servlet FAQ

Lou Umile

Joined: Jan 28, 2010
Posts: 19
I've noticed this issue appear in multiple posts in this sub-forum. I apologize if this is the wrong spot to bring this up, but I think it might be helpful.
I've been reading up on servlet programming in Core Servlets and JavaServer Pages, Vol. 1 by Marty Hall. One of the conventions which this book uses is that the first line of the Document Descriptor is

The author explains that the encoding allows it to work with both serlets 2.3 (JSP 1.2) and servlets 2.4 (JSP 2.0). However, this appears in a number of threads where someone has said that it was causing their servlet to not be recognized. Apparently, in some cases, substituting UTF-8 for ISO-8859-1 has resolved the issue. Since this is a popular book, perhaps this would be a good addition to the FAQ under things to check if your servlet is not working?
Has anyone had this issue with Headfirst Servlets?
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
This is interesting, but it also sounds a bit odd. The encoding of the web.xml file is not supposed to make any difference to the working of the web app.

XML requires that UTF-8 be supported, but not ISO-8859-1, although all major parsers do (certainly all the ones ever shipped with a JRE do). But if a parser encounters a file in an unknown encoding, then it should throw an exception to that effect.

Maybe in the cases were this was reported as the solution, the file was not actually in the encoding that the "encoding" attribute said it was?
I agree. Here's the link:
subject: Possible addition to the Servlet FAQ
It's not a secret anymore!