

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to specify the encoding type used by forms that post data back to the Web application in a JSP?
The <fmt:requestEncoding> tag is used to specify the encoding type used by forms that post data back to the Web application.
Attribute
The <fmt:requestEncoding> tag has the following attributes −
Attribute | Description | Required | Default |
---|---|---|---|
key | Name of character encoding you want to apply when decoding request parameters. | Yes | None |
You use the <fmt:requestEncoding> tag when you want to specify the character encoding for decoding data posted from forms. This tag must be used with character encodings that are different from ISO-8859-1. The tag is required since most browsers do not include a Content-Type header in their requests.
The purpose of the <fmt:requestEncoding> tag is to specify the content type of the request. You must specify the content type, even if the encoding of the page generating the response is specified via the contentType attribute of a page directive. This is because the response's actual locale (and thus character encoding) may differ from the value specified in the page directive.
If the page contains an I18N-capable formatting action that sets the response's locale (and thus character encoding) by calling ServletResponse.setLocale(), any encoding specified in the page directive will be overridden.
Example
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %> <%@ taglib uri = "http://java.sun.com/jsp/jstl/fmt" prefix = "fmt" %> <html> <head> <title>JSTL fmt:message Tag</title> </head> <body> <fmt:requestEncoding value = "UTF-8" /> <fmt:setLocale value = "es_ES"/> <fmt:setBundle basename = "com.tutorialspoint.Example" var = "lang"/> <fmt:message key = "count.one" bundle = "${lang}"/><br/> <fmt:message key = "count.two" bundle = "${lang}"/><br/> <fmt:message key = "count.three" bundle = "${lang}"/><br/> </body> </html>
You will receive the following result −
Uno Dos Tres
- Related Questions & Answers
- How to read form data using JSP via POST Method?
- How to specify the URL of the resource to be used by the object in HTML?
- How to specify the type of box used for an HTML element using CSS?
- Encoding decimal to factorial and back in JavaScript
- How to set the data source in a JSP?
- How to disable back button in android while logging out the application?
- Creating SAP interface to pull data from web application
- How to disable the back button in android while logging out the application using Kotlin?
- How to send data back to the main Activity in android?
- How to specify that the details should be visible to the user in HTML?
- How to specify that the element is read-only in HTML?
- How to secure your data from the Dark Web?
- How to setup a Web server like Tomcat to test JSP pages?
- How to send data back to the Main Activity in Android using Kotlin?
- How to check the memory used by a program in Java?