Use JSP files with chinese characters on FreeBSD with percent encoding











up vote
0
down vote

favorite












We're having Tomcat 8.0.50 in front of Apache2 on a FreeBSD 11.2 machine. The web root contains html and jsp files with chinese characters like 产品.html. Apache can serve those static files fine. But Tomcat throws an error on every file that contains chinese characters.



Example: test企test.jsp result in HTTP Status 404 - /test%E4%BC%81test.jsp



It doesn't matter if the file in the filesystem is percent encoded. When I create a physical file called test%E4%BC%81test.jsp I also get 404 not found. The problem is sure on Tomcats side since I bypassed the Apache2 reverse proxy for testing purpose.



What I already tried



In server.xml:



<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" URIEncoding="UTF-8" redirectPort="8443" />


In web.xml:



<init-param>
<param-name>fileEncoding</param-name>
<param-value>UTF-8</param-value>
</init-param>


bin/setenv.sh (Testing if english fixes the issue)



export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANGUAGE=en_US.UTF-8


bin/catalina.sh



CATALINA_OPTS="$JPDA_OPTS $CATALINA_OPTS -Dfile.encoding=UTF-8"
[...]
JAVA_OPTS="$JAVA_OPTS -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dfile.encoding=UTF-8 -Djava.file.encoding=UTF-8"


Set the following for default in /etc/login.conf:



:charset=UTF-8: 
:lang=de_DE.UTF-8:


Create a custom jsp to list all files in the directory where the jsps with special chars are located:



<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.util.*,javax.mail.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<jsp:scriptlet>
File directory = new File("<path-to-jsp-www>");
File list = directory.listFiles();
pageContext.setAttribute("list", list);

</jsp:scriptlet>

<ul>
<c:forEach items="${list}" var="item">
<li>${item.getAbsolutePath()}</li>
</c:forEach>
</ul>
</html>


This gave me a list of all files where all chinese characters are removed by










share|improve this question
























  • Did you run cap_mkdb after setting login.conf?
    – Claus Andersen
    Nov 29 at 12:33










  • Yes I did. Found out that this problem only appears when Tomcat is started as service. Using catalina.sh start it works. But have no Idea why.
    – Daniel
    Nov 29 at 12:38










  • I would guess that Tomcat does not use "catalina.sh" when starting as a service. But you should have a closer look at /usr/local/etc/rc.d/tomcat to see how you pass the env properly
    – Claus Andersen
    Nov 29 at 12:49















up vote
0
down vote

favorite












We're having Tomcat 8.0.50 in front of Apache2 on a FreeBSD 11.2 machine. The web root contains html and jsp files with chinese characters like 产品.html. Apache can serve those static files fine. But Tomcat throws an error on every file that contains chinese characters.



Example: test企test.jsp result in HTTP Status 404 - /test%E4%BC%81test.jsp



It doesn't matter if the file in the filesystem is percent encoded. When I create a physical file called test%E4%BC%81test.jsp I also get 404 not found. The problem is sure on Tomcats side since I bypassed the Apache2 reverse proxy for testing purpose.



What I already tried



In server.xml:



<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" URIEncoding="UTF-8" redirectPort="8443" />


In web.xml:



<init-param>
<param-name>fileEncoding</param-name>
<param-value>UTF-8</param-value>
</init-param>


bin/setenv.sh (Testing if english fixes the issue)



export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANGUAGE=en_US.UTF-8


bin/catalina.sh



CATALINA_OPTS="$JPDA_OPTS $CATALINA_OPTS -Dfile.encoding=UTF-8"
[...]
JAVA_OPTS="$JAVA_OPTS -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dfile.encoding=UTF-8 -Djava.file.encoding=UTF-8"


Set the following for default in /etc/login.conf:



:charset=UTF-8: 
:lang=de_DE.UTF-8:


Create a custom jsp to list all files in the directory where the jsps with special chars are located:



<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.util.*,javax.mail.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<jsp:scriptlet>
File directory = new File("<path-to-jsp-www>");
File list = directory.listFiles();
pageContext.setAttribute("list", list);

</jsp:scriptlet>

<ul>
<c:forEach items="${list}" var="item">
<li>${item.getAbsolutePath()}</li>
</c:forEach>
</ul>
</html>


This gave me a list of all files where all chinese characters are removed by










share|improve this question
























  • Did you run cap_mkdb after setting login.conf?
    – Claus Andersen
    Nov 29 at 12:33










  • Yes I did. Found out that this problem only appears when Tomcat is started as service. Using catalina.sh start it works. But have no Idea why.
    – Daniel
    Nov 29 at 12:38










  • I would guess that Tomcat does not use "catalina.sh" when starting as a service. But you should have a closer look at /usr/local/etc/rc.d/tomcat to see how you pass the env properly
    – Claus Andersen
    Nov 29 at 12:49













up vote
0
down vote

favorite









up vote
0
down vote

favorite











We're having Tomcat 8.0.50 in front of Apache2 on a FreeBSD 11.2 machine. The web root contains html and jsp files with chinese characters like 产品.html. Apache can serve those static files fine. But Tomcat throws an error on every file that contains chinese characters.



Example: test企test.jsp result in HTTP Status 404 - /test%E4%BC%81test.jsp



It doesn't matter if the file in the filesystem is percent encoded. When I create a physical file called test%E4%BC%81test.jsp I also get 404 not found. The problem is sure on Tomcats side since I bypassed the Apache2 reverse proxy for testing purpose.



What I already tried



In server.xml:



<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" URIEncoding="UTF-8" redirectPort="8443" />


In web.xml:



<init-param>
<param-name>fileEncoding</param-name>
<param-value>UTF-8</param-value>
</init-param>


bin/setenv.sh (Testing if english fixes the issue)



export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANGUAGE=en_US.UTF-8


bin/catalina.sh



CATALINA_OPTS="$JPDA_OPTS $CATALINA_OPTS -Dfile.encoding=UTF-8"
[...]
JAVA_OPTS="$JAVA_OPTS -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dfile.encoding=UTF-8 -Djava.file.encoding=UTF-8"


Set the following for default in /etc/login.conf:



:charset=UTF-8: 
:lang=de_DE.UTF-8:


Create a custom jsp to list all files in the directory where the jsps with special chars are located:



<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.util.*,javax.mail.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<jsp:scriptlet>
File directory = new File("<path-to-jsp-www>");
File list = directory.listFiles();
pageContext.setAttribute("list", list);

</jsp:scriptlet>

<ul>
<c:forEach items="${list}" var="item">
<li>${item.getAbsolutePath()}</li>
</c:forEach>
</ul>
</html>


This gave me a list of all files where all chinese characters are removed by










share|improve this question















We're having Tomcat 8.0.50 in front of Apache2 on a FreeBSD 11.2 machine. The web root contains html and jsp files with chinese characters like 产品.html. Apache can serve those static files fine. But Tomcat throws an error on every file that contains chinese characters.



Example: test企test.jsp result in HTTP Status 404 - /test%E4%BC%81test.jsp



It doesn't matter if the file in the filesystem is percent encoded. When I create a physical file called test%E4%BC%81test.jsp I also get 404 not found. The problem is sure on Tomcats side since I bypassed the Apache2 reverse proxy for testing purpose.



What I already tried



In server.xml:



<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" URIEncoding="UTF-8" redirectPort="8443" />


In web.xml:



<init-param>
<param-name>fileEncoding</param-name>
<param-value>UTF-8</param-value>
</init-param>


bin/setenv.sh (Testing if english fixes the issue)



export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANGUAGE=en_US.UTF-8


bin/catalina.sh



CATALINA_OPTS="$JPDA_OPTS $CATALINA_OPTS -Dfile.encoding=UTF-8"
[...]
JAVA_OPTS="$JAVA_OPTS -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dfile.encoding=UTF-8 -Djava.file.encoding=UTF-8"


Set the following for default in /etc/login.conf:



:charset=UTF-8: 
:lang=de_DE.UTF-8:


Create a custom jsp to list all files in the directory where the jsps with special chars are located:



<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.util.*,javax.mail.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<jsp:scriptlet>
File directory = new File("<path-to-jsp-www>");
File list = directory.listFiles();
pageContext.setAttribute("list", list);

</jsp:scriptlet>

<ul>
<c:forEach items="${list}" var="item">
<li>${item.getAbsolutePath()}</li>
</c:forEach>
</ul>
</html>


This gave me a list of all files where all chinese characters are removed by







filesystems freebsd java locale






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 28 at 16:53

























asked Nov 28 at 14:25









Daniel

11




11












  • Did you run cap_mkdb after setting login.conf?
    – Claus Andersen
    Nov 29 at 12:33










  • Yes I did. Found out that this problem only appears when Tomcat is started as service. Using catalina.sh start it works. But have no Idea why.
    – Daniel
    Nov 29 at 12:38










  • I would guess that Tomcat does not use "catalina.sh" when starting as a service. But you should have a closer look at /usr/local/etc/rc.d/tomcat to see how you pass the env properly
    – Claus Andersen
    Nov 29 at 12:49


















  • Did you run cap_mkdb after setting login.conf?
    – Claus Andersen
    Nov 29 at 12:33










  • Yes I did. Found out that this problem only appears when Tomcat is started as service. Using catalina.sh start it works. But have no Idea why.
    – Daniel
    Nov 29 at 12:38










  • I would guess that Tomcat does not use "catalina.sh" when starting as a service. But you should have a closer look at /usr/local/etc/rc.d/tomcat to see how you pass the env properly
    – Claus Andersen
    Nov 29 at 12:49
















Did you run cap_mkdb after setting login.conf?
– Claus Andersen
Nov 29 at 12:33




Did you run cap_mkdb after setting login.conf?
– Claus Andersen
Nov 29 at 12:33












Yes I did. Found out that this problem only appears when Tomcat is started as service. Using catalina.sh start it works. But have no Idea why.
– Daniel
Nov 29 at 12:38




Yes I did. Found out that this problem only appears when Tomcat is started as service. Using catalina.sh start it works. But have no Idea why.
– Daniel
Nov 29 at 12:38












I would guess that Tomcat does not use "catalina.sh" when starting as a service. But you should have a closer look at /usr/local/etc/rc.d/tomcat to see how you pass the env properly
– Claus Andersen
Nov 29 at 12:49




I would guess that Tomcat does not use "catalina.sh" when starting as a service. But you should have a closer look at /usr/local/etc/rc.d/tomcat to see how you pass the env properly
– Claus Andersen
Nov 29 at 12:49















active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f484678%2fuse-jsp-files-with-chinese-characters-on-freebsd-with-percent-encoding%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f484678%2fuse-jsp-files-with-chinese-characters-on-freebsd-with-percent-encoding%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Morgemoulin

Scott Moir

Souastre