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 �
filesystems freebsd java locale
add a comment |
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 �
filesystems freebsd java locale
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. Usingcatalina.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
add a comment |
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 �
filesystems freebsd java locale
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
filesystems freebsd java locale
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. Usingcatalina.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
add a comment |
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. Usingcatalina.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
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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