I need to encode all of my JSPs as UTF-8.
I've looked around and found that I can use the following page directive to accomplish this:
<%@page pageEncoding="UTF-8"%>
This works perfectly, but I need a way to include that directive to all of my JSPs. I don't want to paste it at the top of each JSP file in my project.
I have a header file that all my JSPs use to display the page header. I'd like to be able to set the page encoding in the included header file, and have it apply to the page that's including it. Unfortunately, from reading this, it looks like the <%@ page %>
directive only carries on to the children includes, so I can't just set the encoding in the header because the encoding won't be inherited by the actual page.
Can anyone give me a clean way to set the character encoding on all of my JSPs?
Put the following in your web.xml
to achieve the goal.
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<page-encoding>UTF-8</page-encoding>
</jsp-property-group>
</jsp-config>
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