What's the best way to specify page encoding - using a page directive like this?
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
Or should I directly put it in a meta tag?
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head>
Eclipse by default uses both, so does that mean I need both?
The contentType attribute sets the character encoding for the JSP page and for the generated response page. The default content type is text/html, which is the standard content type for HTML pages.
You don't need both. Actually, <%@ page pageEncoding="utf-8" %>
suffices.
I would think that you need both, don't you? My guess is that the page directive tells the Container to compile the JSP using the specified encoding and the meta tag tells the browser how the page is encoded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With