HttpServletResponse also allows you to send pre-defined error messages. For example, SC_FORBIDDEN will be translated into an HTTP error 403. Along with the error code, you also can send a custom error message.
HttpServletResponse also allows you to send pre-defined error messages. For example, SC_FORBIDDEN will be translated into an HTTP error 403. Along with the error code, you also can send a custom error message.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online from Scribd
HttpServletResponse also allows you to send pre-defined error messages. For example, SC_FORBIDDEN will be translated into an HTTP error 403. Along with the error code, you also can send a custom error message.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online from Scribd
The HttpServletResponse also allows you to send pre-defined error messages. The interface defines a number of public static final integers that all start with SC_. For example, SC_FORBIDDEN will be translated into an HTTP error 403. Along with the error code, you also can send a custom error message. Instead of redisplaying the Login page when a failed login occurs, you can send an HTTP error 403 plus your error message. To do this, replace the call to the sendLoginForm in the doPost method with the following: response.sendError(response.SC_FORBIDDEN, "Login failed.");
Sending Special Characters
To get around this, every time you want to display a special character, you need to encode it. The less-than character (<) is encoded as "<" and the greater-than character (>) as ">". Other special characters are the ampersand (&) and double quotation mark (") characters. You replace the ampersand (&) with "&" and the double quotation marks (") with """. Additionally, two or more white spaces are always displayed as a single space, unless you convert each individual space to " ".