Red Hat NETSCAPE ENTERPRISE SERVER 6.0 - NSAPI PROGRAMMER GUIDE Bedienungsanleitung Seite 74

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 124
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 73
Clarifications for Using Methods
74 iPlanet Web Server, Enterprise Edition Programmer’s Guide to Servlets • May 2001
ServletRequest.getParameter
public java.lang.String getParameter(java.lang.String name)
Retrieves the value associated with a parameter name.
Clarification
When your form fields contain non-UTF-8 characters, you must do one of the
following, or the values extracted by the
getParameter method are zeros or are
undefined:
Set the
enc attribute of the parameter-encoding element to auto (the default)
in the
web-apps.xml file. For more information, see “parameter-encoding,” on
page 22.
Set the
parameterEncoding property to auto (the default) or responseCT in
the
contexts.properties file, as in iPlanet Web Server 4.x. For more
information, see “parameterEncoding,” on page 92.
Because the original encoding used to enter data into form fields is lost when the
data is URL-encoded, you must do the following:
Always set the response content type when sending a form to a client. This
ensures that the entire form gets safely to the client.
When sending form data to a server that uses a different locale than the form
fields, you must tell the server the
charset before you call the getParameter
method, as follows:
If the servlet or JSP that generated the form is different than the one
processing the form, use a hidden field in the form (called
j_encoding by
default), for example:
<input type="hidden" name="j_encoding" value="US_ASCII">
Set the com.iplanet.server.http.servlet.parameterEncoding
attribute in the request object (see “ServletRequest.setAttribute,” on page
73). The
getParameter method uses this attribute to decode the
parameters.
If parameterEncoding=responseCT in contexts.properties and the
same servlet or JSP generates and processes the form, you can set the
response content type. For servlets, explicitly set it as in this example:
res.setContentType("text/plain; charset=Shift_JIS");
Seitenansicht 73
1 2 ... 69 70 71 72 73 74 75 76 77 78 79 ... 123 124

Kommentare zu diesen Handbüchern

Keine Kommentare