John Rumpel
John Rumpel

Reputation: 4615

JSP: Set character default encoding for each request/response

Is there a way to set default encoding type without the need to explicitly invoke

response.setCharacterEncoding("UTF-8");
request.setCharacterEncoding("UTF-8");

for each request/response?

Upvotes: 0

Views: 982

Answers (1)

McDowell
McDowell

Reputation: 108899

The content type can be set in the JSP:

<%@page language="java" contentType="text/html; charset=UTF-8"
  pageEncoding="UTF-8"%>

It isn't usual to set the encoding on the request. It suggests a defect somewhere else in the application. But if you want to set these things explicitly and globally, use a Filter.

Upvotes: 1

Related Questions