• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Strange problem with Oreilly servlet package

 
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey All, Ive been using the MulipartRequest section of the Oreilly servlet package for quite a while now with great results but something VERY strange happened last week. First of all let me explain how Im using it. I am doing simple uploads of a file (comma deliminated data) to a server. My prog then parse thru the data to clean it out & enter it into a db. I have used it both on the Linux server & my win2k machine (for developing & testing) for over 6 months without so much as a single glitch.
Last week I got a new hard drive, backed everything up & re-installed win2k. I reset up my servlet engine (Resin) & reset up my development package for this program. Prior to the new hard drive I uploaded the 5-10 meg files (not really an upload its coming from the same partition on my hard drive)in a matter of seconds. Ever since I re-setup my machine it takes 3-10 minutes to complete the task. I put some printlines in my code & found that it was hanging during the actual upload process. I re-downloaded the Oreilly package, think it was corrupt but that didnt help anything. I have also recompiled with no change. Strange thing is I just updated the program on the Linux box yesterday & it uploads these same files in seconds! I am REALLY stumped here! Its not crucial as long as the server keeps working fine but its REAL annoying testing on my machine. Anyone know what win gremlin this could be? Here's my code, just in case:
package challenge.dbUtil;
import java.io.File;
import com.oreilly.servlet.MultipartRequest;
/**
* Class uploads the deliminated file (picked by user) to the server & renames it to the appropriate name.
* @author DC Dalton
* @version 1.0
*/
public class UploadFile extends javax.servlet.http.HttpServlet {
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException{
super.init(config);
}
public void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws javax.servlet.ServletException, java.io.IOException{
javax.servlet.ServletContext sc = getServletContext();
res.setContentType("text/html");
java.io.PrintWriter out = res.getWriter();
StringBuffer sb = new StringBuffer();
challenge.pages.ProgramHtml prog = new challenge.pages.ProgramHtml();
/* Show upload form */
if (req.getParameter("show_form") != null){
prog.drawPageTop(sb, "SOS File Upload Form");
sb = challenge.pages.UploadForm.getForm(sb);
}
/* upload file to correct directory & rename it to test.sos */
else{
MultipartRequest mp = new MultipartRequest(req, sc.getRealPath("/WEB-INF/classes/sos/"), 50000000);
File oldFile = mp.getFile("file_to_upload");
File newFile = new File(sc.getRealPath("/WEB-INF/classes/sos/test.sos"));
if (newFile.exists()){
newFile.delete();
}
oldFile.renameTo(newFile);
/*Set Tracker Object's upload field to 1 so link will go away */
Tracker tk = new Tracker();
tk.setUpload(1);
/*Show success page */
prog.drawPageTop(sb, "File Upload Success");
sb = challenge.pages.UploadSuccess.showSuccess(sb);
}
prog.drawPageBottom(sb);
out.println(sb.toString());
out.close();
}
public void doGet (javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws javax.servlet.ServletException, java.io.IOException{
doPost(req, res);
}
};
 
reply
    Bookmark Topic Watch Topic
  • New Topic