Actually, the servlet has only a doPost method. The engine is
Tomcat 4.1.24.
It is same in my office. My problem is still having.
Code:
public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String dir = ".";
try{
out.println("Upload
Test start...");
//MultipartRequest multi = new MultipartRequest(req,".",5*1024*1024);
MultipartRequest multi = new MultipartRequest(req,dir,5*1024*1024);
out.println("123");
out.println("<html>");
out.println("<head><title>UploadTest</title></head>");
out.println("<body>");
out.println("<H1>UploadTest</h1>");
out.println("<h3>Params:</h3>");
out.println("<Pre>");
Enumeration params = multi.getParameterNames();
while(params.hasMoreElements()){
String name=(String)params.nextElement();
String value =multi.getParameter(name);
out.println(name + " = " + value);
}
out.println("</PRE>");
out.println("<h3>Files:</h3>");
out.println("<pre>");
Enumeration files=multi.getFileNames();
while(files.hasMoreElements()){
String name = (String)files.nextElement();
String filename = multi.getFilesystemName(name);
String type = multi.getContentType(name);
File f=multi.getFile(name);
out.println("name: "+name);
out.println("filename: "+filename);
out.println("type: "+ type);
if(f != null){
out.println("length: "+f.length());
out.println();
}
out.println("</pre>");
}
}
catch(Exception e){
out.println("<pre>");
e.printStackTrace(out);
out.println("<pre>");
}
out.println("</body></html>");
}
}