[
https://issues.jboss.org/browse/WFLY-2265?page=com.atlassian.jira.plugin....
]
Claudio Miranda commented on WFLY-2265:
---------------------------------------
Hi, I tested the following code in WF 8.0.0.Final (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 ?
WebUtils#getRealPath("config-data/TESTDEV") cannot be
resolved to absolute file path
------------------------------------------------------------------------------------
Key: WFLY-2265
URL:
https://issues.jboss.org/browse/WFLY-2265
Project: WildFly
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: Web (Undertow)
Affects Versions: 8.0.0.Beta1
Environment: Windows 7
Reporter: zhihong liu
Assignee: Tomaz Cerar
Labels: jboss
Fix For: 8.0.0.Final
Original Estimate: 3 weeks
Remaining Estimate: 3 weeks
In windows , when use the WebUtils.getRealPath("config-data/TESTDEV") , it
returns error message : ServletContext resource [/config-data/TESTDEV] cannot be resolved
to absolute file path.
but WebUtils.getRealPath("/") can return the true path . that is to say , this
method can't parse the backslash followed by a string . but it works good in
linux/unix .
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira