Polskie litery w serwletach

0

Serwlet tworzy całą stronę - frgament metody doGet(...)

    response.setContentType("text/html;encoding=iso-8859-2");
    out.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\">");
    out.println("<html><head><title>Witam z servletu</title><meta http-equiv=\"Content-Type\"  content=\"text/html; charset=ISO-8859-2\"></head>");

Co mam zmienić

  • w deklaracjach strony kodowej
  • konfiguracji Tomcata
    ...
    żeby teksty napisane w kodzie serwletu w standardzie iso-8859-2 były poprawnie wyświetlone w przeglądarce?
0

Z API:
setContentType

void setContentType(String type)

Sets the content type of the response being sent to the client, if the response has not been committed yet. The given content type may include a character encoding specification, for example, text/html;charset=UTF-8. The response's character encoding is only set from the given content type if this method is called <b>before getWriter is called</b>. 

Z Twojego kodu wyglada na to ze getWriter wolales zanim wolales setContentType (zmienna out jest juz dostepna). Sprobuj zrobic jak API podaje.

0

Niestety nie pomogło.

0

Jeszcze jedno w setContentType powinienes miec to co w meta czyli "text/html; charset=iso-8859-2" a nie "text/html; encoding=iso-8859-2". Jak generujesz pozniej meta to lepiej dynamicznie wyciagnac ta wartosc z responsa. Testowalem u mnie dziala ;-)

0

Pomogło, dzięki.

1 użytkowników online, w tym zalogowanych: 0, gości: 1