This is mySourceCode ...
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.io.File"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
ServletContext sc = request.getSession().getServletContext();
java.io.File fi = new File(sc.getRealPath("/file"));
java.io.File listFile[] = fi.listFiles();
for(int i=0;i<listFile.length;i++){
out.println("<br><a href=TesDownload?namaFile="+listFile.getName()+">" +listFile.getName() +"</a><br>");
}
%>
</body>
</html>
but i have a problem
An error occurred at line: 16 in the jsp file: /file/WEB-INF/index.jsp
Cannot invoke getName() on the array type File[]
13:
14: java.io.File listFile[] = fi.listFiles();
15: for(int i=0;i<listFile.length;i++){
16: out.println("<br><a href=TesDownload?namaFile="+listFile.getName()+">" +listFile.getName() +"</a><br>");
17: }
18:
19: %>
An error occurred at line: 16 in the jsp file: /file/WEB-INF/index.jsp
Cannot invoke getName() on the array type File[]
13:
14: java.io.File listFile[] = fi.listFiles();
15: for(int i=0;i<listFile.length;i++){
16: out.println("<br><a href=TesDownload?namaFile="+listFile.getName()+">" +listFile.getName() +"</a><br>");
17: }
18:
19: %>
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.jav acError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacEr ror(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateCla ss(JDTCompiler.java:435)
org.apache.jasper.compiler.Compiler.compile(Compil er.java:298)
org.apache.jasper.compiler.Compiler.compile(Compil er.java:277)
org.apache.jasper.compiler.Compiler.compile(Compil er.java:265)
org.apache.jasper.JspCompilationContext.compile(
Js pCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:299)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet .java:803)
help me please
Fuad Lutfi