0 Replies - 1070 Views - Last Post: 27 April 2012 - 09:01 PM

#1 Jay0830  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 58
  • Joined: 01-June 10

Create a folder or file in Host

Posted 27 April 2012 - 09:01 PM

Hi, guys,
recently, I rent a tomcat host and I upload my jsp website to the host.
only one thing that doesn't work is uploading page.
I am not sure the uploading is work or not, but I can't even create a file or folder in my host.
I create a simple jsp that create a direct.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<%@page import="java.io.*"  %>
</head>
<body>
<%
java.io.File file = new File("/path/to/my/user/folder/t.txt");
if(!file.getParentFile().exists())
{
	try{
    if(file.mkdirs()){
    	out.println("yes");
    }else{
    	out.println("no");
    }
	}catch(Exception e){
		out.println(e.getMessage());
	}
}
if(file.mkdir()){
	out.println("yes");
}else{
	out.println("no");
}
out.println(file.getAbsolutePath());

String path = request.getContextPath();
String basePath = request.getScheme()+"://>/"+request.getServerName()+":"+request.getServerPort()+path+"/";

out.println(basePath);
%>
</body>
</html>


it returns "no" which means I can't even create a folder or file.
it's my first time to do things in web host.
usually I run my website in my computer as a server.
therefore, I don't really know if I need to set anything up in order to create a file in the host.

Thanks

Is This A Good Question/Topic? 0
  • +

Page 1 of 1