在远程系统上,java的isDirectory函数工作不正常
我有一个jsp网页,当我在系统中运行时,就像使用本地服务器一样,它在工作(.isdirectory),但当我试图在某个在线服务器上托管我的网页时,它会给出一些错误。我搜索了这么多网站,但没有人有正确的答案,请告诉我,你可以给出一些替代解决方案吗在远程系统上,java的isDirectory函数工作不正常,java,jsp,jakarta-ee,Java,Jsp,Jakarta Ee,我有一个jsp网页,当我在系统中运行时,就像使用本地服务器一样,它在工作(.isdirectory),但当我试图在某个在线服务器上托管我的网页时,它会给出一些错误。我搜索了这么多网站,但没有人有正确的答案,请告诉我,你可以给出一些替代解决方案吗 <% str=request.getParameter("path"); if(str!=null && str!="") { File file=new File(str); lengh=str.leng
<% str=request.getParameter("path");
if(str!=null && str!="")
{
File file=new File(str);
lengh=str.length();
if(str.substring(lengh-7,lengh).equals("xyz")&& file.isdirectory()){
str1=str+"\\new\\";
str2=str1+"bitcoin.pdf";
try {
url = new URL("https://bitcoin.org/bitcoin.pdf");
URLConnection con = url.openConnection();
in = new BufferedInputStream(con.getInputStream());
ou = new FileOutputStream(str2);
int i = 0;
byte[] bytesIn = new byte[1024];
while ((i = in.read(bytesIn)) >= 0) {
ou.write(bytesIn, 0, i);
}
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
if(ou!=null){
ou.close();
ou=null;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
if(in!=null){
in.close();
in=null;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
%><div class="container"><div class="alert alert-success">Success! Well done its Downloaded.</div></div><%
System.out.printf("success");
}else{
%><script>
window.alert("Please Enter valid path");
</script><%
}
} else if(str==""){
%><script>
window.alert("Please Enter folder name");
</script><%
}%>
=0){
写(bytesIn,0,i);
}
}捕获(例外e){
e、 printStackTrace();
}最后{
试一试{
如果(ou!=null){
ou.close();
ou=null;
}
}捕获(IOE异常){
//TODO自动生成的捕捉块
e、 printStackTrace();
}
试一试{
if(in!=null){
in.close();
in=null;
}
}捕获(IOE异常){
//TODO自动生成的捕捉块
e、 printStackTrace();
}
}
%>成功!做得很好。
window.alert(“请输入有效路径”);
window.alert(“请输入文件夹名称”);
您的托管提供商是否允许您直接访问文件系统?很抱歉-if(str.substring(lengh-7,lengh).equals(“xyz”)&&file.isdirectory())@hexafrance我不知道我正在使用免费的web托管站点