-
15. Re: Why the deployment of application in Wildfly can't access the web root directory?
ctomc Oct 21, 2013 6:35 AM (in response to kobe_fans)Were do you see a problem?
if file(which can be directory or file) exists, then return FileResource otherwise it returns null, which is perfectly valid logic.
or do you have something else in mind?
From first look at the code it looks it should work properly.
-
16. Re: Why the deployment of application in Wildfly can't access the web root directory?
kobe_fans Oct 22, 2013 12:15 AM (in response to ctomc)Maybe i didn't describe my trouble clearly , If you can write a small sample project and write this code "WebUtils.getRealPath("/config-data")" in your procedure and print the result in browser . Maybe a servlet is just enough . then , Deploy applications on the wildfly and through the browser to access your application . If so, maybe my problem also appeared .
-
17. Re: Why the deployment of application in Wildfly can't access the web root directory?
ctomc Oct 27, 2013 4:10 PM (in response to kobe_fans)Just bit of update about this. I have it on my todo for this coming week.
That code you see there looks perfectly fine, maybe you are concerned because of using File object, File can be directory or file. to be fair it is not the best api there is
-
18. Re: Why the deployment of application in Wildfly can't access the web root directory?
kobe_fans Oct 28, 2013 6:34 AM (in response to ctomc)Hi , @Tomaz .
Maybe i met another trouble again , Beacuse it's very urgent , So I said here.
How do i set the encoding of wildfly according to the different get/post requests , I want to change the default encode of wildfly "ISO-8859-1" to "UTF-8" , Should i change some configruation file , Beacuse I want to let wildfly to support chinese under standalone mode . I had tried every possible method but it didn't work . So could you give me some suggestions .
Thanks
-
19. Re: Why the deployment of application in Wildfly can't access the web root directory?
ctomc Oct 28, 2013 6:54 AM (in response to kobe_fans)That configuration is exposed by PR I just sent in https://github.com/wildfly/wildfly/pull/5347
When it is merged you can set encoding on listener.
-
20. Re: Why the deployment of application in Wildfly can't access the web root directory?
kobe_fans Nov 1, 2013 12:12 AM (in response to ctomc)Ok , Tomaz
The encoding problem is resolved with the nightly build , It works good with "utf-8" in version of wildfly-8.0.0.Beta2-SNAPSHOT .
Thanks a lot !
-
21. Re: Re: Why the deployment of application in Wildfly can't access the web root directory?
claudio4j Jan 21, 2014 5:08 PM (in response to kobe_fans)Hi, I tested the following code in WF 8.0.0.Final-SNAPSHOT (cloned from repo on 2014-01-21), and it works, see
@WebServlet(value="/get") public class GetPath extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { OutputStreamWriter os = new OutputStreamWriter(resp.getOutputStream()); os.write("<html><body>"); ServletContext sc = getServletContext(); String file1 = sc.getRealPath("/"); print(os, "sc root file path: " + file1); file1 = sc.getRealPath("dir/file.txt"); print(os, "sc file path: " + file1); file1 = req.getRealPath("dir/file.txt"); print(os, "req file path: " + file1); InputStream is = sc.getResourceAsStream("/dir/file.txt"); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line = null; print(os, "===> dentro do arquivo"); while ( (line = br.readLine()) != null) { print(os, line); } os.write("</body></html>"); os.flush(); os.close(); } public void print(OutputStreamWriter out, String m) throws IOException { out.write("<p>" + m + "</p>"); }
Accessing the url at /getpath/get just works and returns the path and file content.
Zhihong, can you try with the latest WF 8.0.0.Final-SNAPSHOT or nightly build ?
-
22. Re: Re: Why the deployment of application in Wildfly can't access the web root directory?
kobe_fans Feb 17, 2014 8:47 PM (in response to claudio4j)I'm very sorry so long time to reply to your , Thank you !