This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Strange problem with Oreilly servlet package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Strange problem with Oreilly servlet package" Watch "Strange problem with Oreilly servlet package" New topic
Author

Strange problem with Oreilly servlet package

DC Dalton
Ranch Hand

Joined: May 28, 2001
Posts: 287
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);
}
};
 
wood burning stoves
 
subject: Strange problem with Oreilly servlet package
 
Similar Threads
SOS
file upload sos
SOS
Uploading files
help help help SOS