Hi
I would like to implement an interface called FileRenamePolicy from the
oreilly package for uploading files, and I am creating a class which
does the implementation.
Here is the relevant code:
<%@ page session="true"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.net.*" %>
<%@ page import="java.text.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.oreilly.servlet.*" %>
<%@ page import="com.oreilly.servlet.multipart.*" %>
<%
abstract class reName implements FileRenamePolicy {
public File changename (File oldname) {
DefaultFileRenamePolicy dfrp = new DefaultFileRenamePolicy();
FileRenamePolicy frp = (FileRenamePolicy) dfrp;
File savename = frp.rename(oldname);
return savename;
}
}
%>
Apparently this class needed to be abstract for the jsp to compile.
Later on in the code, I would like to rename the file. First I create a
MultipartRequest object:
MultipartRequest mr = new
MultipartRequest(request,"/var/www/projects_data/");
Then I upload the file object:
File oldn = mr.getFile(mr.getParameter("audit_doc"));
And then I rename the file:
File newname = reName.changename(oldn);
But here is when I get the error:
"non-static method changename(java.io.File) cannot be referenced from a
static context"
What does this mean and what am I doing wrong?
After I rename the file, I would still like do download it (using the
new filename) to /var/www/projects_data/.
I think I have to use a method from the oreilly package named
FilePart.writeTo().
Would anyone be able to give me a hint on how to use this?
Any help, especially code examples, will be greatly appreciated.
Thanks
Hugo
--
Dr Hugo Bouckaert
Systems and Programming Engineer
GeoInformatics Exploration Australia P/L
57 Havelock St
West Perth, WA 6005
PO Box 1675, West Perth 6872
Ph: 61 08 9420 7400
Fax: 61 08 9226 1299
www.geoinformex.com
------------------------------------------------------------------------
This email and any attachments may be confidential or legally
privileged. If you received this message in error or are not the
intended recipient, you should destroy the e-mail message and any
attachments or copies, and you are prohibited from retaining,
distributing, disclosing or using any information contained herein.
Please inform us of the erroneous delivery by return e-mail. Thank you
for your cooperation.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com