Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 11th, 2007, 10:29 PM
Registered User
 
Join Date: Jul 2007
Location: Tangerang, Jl KH Agus Salim Tanah Tinggi, Indonesia.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cannot invoke getName() on the array type File[]

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
Reply With Quote
  #2 (permalink)  
Old July 13th, 2007, 03:43 AM
Registered User
 
Join Date: Jul 2007
Location: Tangerang, Jl KH Agus Salim Tanah Tinggi, Indonesia.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

listFile array --> listFile[i].getName()

thanks :D

Fuad Lutfi
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Go from 2d Array to 1d array without defining type OneQuestion General .NET 1 January 10th, 2008 11:13 AM
Working with array-type elements tclotworthy XSLT 2 October 11th, 2007 09:27 AM
Passing a Array in of no specifc type.. John Pennington Pro VB 6 1 September 27th, 2006 05:04 PM
<input type="File"> - Specify File Type and Path gp_mk Classic ASP Basics 2 August 2nd, 2004 03:07 AM
How can I invoke an .rtf file with VB? aster Pro VB 6 3 February 13th, 2004 11:56 AM



All times are GMT -4. The time now is 04:36 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.