ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Using the Jakarta Commons, Part 1
Subject:   getName issue on HP-UX
Date:   2003-10-14 23:05:27
From:   dennys
This program is ok on JDK 1.3.1 for Windows.
But when I deploy it to JDK 1.3.1 for HP-UX 11i,
I found that item.getName() or fullFile.getName() return the full path.


My workaround method is the following code:
while(itr.hasNext()) { FileItem item = (FileItem) itr.next(); if (item.isFormField()) { String fieldname = item.getFieldName(); } else { out.println("Source File:" + item.getName() + "<br/>"); out.println("Target Dir: " + getServletContext().getRealPath("/") + "<br/>"); int i = item.getName().lastIndexOf('\\'); File savedFile = new File(getServletContext().getRealPath("/"), item.getName().substring(i+1) ); item.write(savedFile); out.println("<br/>"); parseExcel(out, item.getName().substring(i+1)); } }


But because it detects the backslash ("\") word, I think it only support Windows client. But it support Windows and HP-UX server now.