I also found that example overcomplicated. Below is the servlet class I use - you'll be able to do away with some of the request.getParameters (the stuff to do with "quickTip" etc, depending on how your client page looks. Also below is the client code you need which hits the servlet....
import java.io.*;
import java.util.*;
import javax.servlet.http.*;
import javax.servlet.*;
public class UploadServlet extends HttpServlet {
String to = null;
String data = null;
ServletContext servletContext;
public void init(ServletConfig servletConfig) throws ServletException {
super.init( servletConfig );
servletContext = servletConfig.getServletContext();
System.out.println("Initializing ..."

;
}
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doGet(req, resp);
}
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
HttpSession session = req.getSession(true);
PrintWriter out = null;
DataInputStream in = null;
FileOutputStream fileOut = null;
String rootPath = (String)session.getAttribute("fileNamePathToSaveTo"

;
String fileName = null;
//int MAX_SIZE = 50 * 1024; // 50 Mb
try {
resp.setContentType("text/html"

;
String contentType = req.getContentType();
System.out.println("Content type is :: " +contentType);
//java.util.Enumeration enum = req.getParameterNames();
//while(enum.hasMoreElements()) {
// System.out.println(" param = " + (String)enum.nextElement());
//}
if ((contentType != null) && (contentType.indexOf("multipart/form-data"

>= 0)) {
in = new DataInputStream(req.getInputStream());
int formDataLength = req.getContentLength();
byte dataBytes[] = new byte[formDataLength];
int byteRead = 0;
int totalBytesRead = 0;
while (totalBytesRead < formDataLength) {
byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
totalBytesRead += byteRead;
}
String file = new String(dataBytes);
String saveFile = file.substring(file.indexOf("filename=\""

+ 10);
saveFile = saveFile.substring(0, saveFile.indexOf("\n"

);
saveFile = saveFile.substring(saveFile.lastIndexOf("\\"

+ 1,saveFile.indexOf("\""

);
int lastIndex = contentType.lastIndexOf("="

;
String boundary = contentType.substring(lastIndex + 1,contentType.length());
fileName = new String(rootPath +saveFile);
int pos;
pos = file.indexOf("filename=\""

;
pos = file.indexOf("\n", pos) + 1;
pos = file.indexOf("\n", pos) + 1;
pos = file.indexOf("\n", pos) + 1;
int boundaryLocation = file.indexOf(boundary, pos) - 4;
int startPos = ((file.substring(0, pos)).getBytes()).length;
int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
//File fileDir = new File(rootPath);
//if (!fileDir.exists()) {
// fileDir.mkdirs();
//}
fileOut = new FileOutputStream(fileName);
//fileOut.write(dataBytes);
fileOut.write(dataBytes, startPos, (endPos - startPos));
fileOut.flush();
fileOut.close();
} else if (contentType.equals("application/x-
{
fileName = req.getParameter("quickTipFileName"

;
if (fileName.length() < 3) {
doError(req, resp, "You have not entered a filename !", session);
return;
}
fileName = (rootPath +fileName);
PrintWriter pw = new PrintWriter(new FileOutputStream(fileName));
if (!(new File(rootPath +fileName)).exists()) {
pw.println("<HTML><BODY>"

;
pw.println(req.getParameter("quickTip"

);
pw.println("</HTML></BODY>"

;
} else {
pw.println(req.getParameter("quickTip"

);
}
pw.flush();
pw.close();
} else {
System.out.println("request not multipart /form - data " + contentType);
doError(req, resp, "request not multipart /form - data " + contentType, session);
}
System.out.println("!!! File written to : " + fileName);
doSuccess(req, resp, "File written to " + fileName, session);
}
catch (Exception e) {
System.out.println("Error : " + e.getMessage());
doError(req, resp, "Error : " + e.getMessage(), session);
}
}
public void doSuccess(HttpServletRequest request, HttpServletResponse response, String message, HttpSession session) throws ServletException, IOException {
// Handle successful transactions, and forward control to skbSuccess.jsp
session.setAttribute("message", message);
RequestDispatcher rd = getServletContext().getRequestDispatcher("/skbSuccess.jsp"

;
rd.forward(request, response);
}
public void doError(HttpServletRequest request, HttpServletResponse response, String message, HttpSession session) throws ServletException, IOException {
// Handle caught errors, and forward control to skbError.jsp
session.setAttribute("message", message);
RequestDispatcher rd = getServletContext().getRequestDispatcher("/skbError.jsp"

;
rd.forward(request, response);
}
}
-----------------------------------
-----------------------------------
---------------------------------
client code ----------------------
-------------------------------------
<HTML>
<BODY>
Choose a file to upload, or enter some text to be added as a 'quick tip' ...
<FORM ACTION="/components/servlet/UploadServlet" ENCTYPE="multipart/form-data" METHOD="post" >
<HR>
<INPUT TYPE="file" NAME="fileToUpload"> <BR>
<INPUT TYPE="submit" VALUE="UpLoad">
</FORM>
</BODY>
</HTML>