JSP作业

JSP作业
文本预览:

if (strBuff.startsWith(boundary)) { if (name != null && name.trim().length() > 0) { if (fileFlag) { bos.flush(); baos.close(); bos.close(); baos = null; bos = null;

updFileArr.add(fName); } else { Object obj = paramHt.get(name); ArrayList al = new ArrayList(); if (obj != null) { al = (ArrayList) obj; } al.add(value); System.out.println(value); paramHt.put(name, al); } } name = new String(); value = new String(); fileFlag = false; fName = new String(); rtnPos = sis.readLine(buffs, 0, buffs.length); if (rtnPos != -1) { strBuff = new String(buffs, 0, rtnPos); if (strBuff.toLowerCase().startsWith( "content-disposition: form-data; ")) { int nIndex = strBuff.toLowerCase().indexOf( "name=\""); int nLastIndex = strBuff.toLowerCase().indexOf( "\"" nIndex + 6); name = strBuff.substring(nIndex + 6, nLastIndex); } int fIndex = strBuff.toLowerCase().indexOf( "filename=\""); if (fIndex != -1) { fileFlag = true; int fLastIndex = strBuff.toLowerCase().indexOf( "\"" fIndex + 10); fName = strBuff.substring(fIndex + 10, fLastIndex); fName = getFileName(fName); if (fName == null || fName.trim().length() == 0) { fileFlag = false; sis.readLine(buffs, 0, buffs.length);

sis.readLine(buffs, 0, buffs.length); sis.readLine(buffs, 0, buffs.length); continue; }else{ fName = getFileNameByTime(fName); sis.readLine(buffs, 0, buffs.length); sis.readLine(buffs, 0, buffs.length); } } } } else if (strBuff.startsWith(endBoundary)) { if (name != null && name.trim().length() > 0) { if (fileFlag) { bos.flush(); baos.close(); bos.close(); baos = null; bos = null; updFileArr.add(fName); } else { Object obj = paramHt.get(name); ArrayList al = new ArrayList(); if (obj != null) { al = (ArrayList) obj; } al.add(value); paramHt.put(name, al); } } } else { if (fileFlag) { if (baos == null && bos == null) { tmpFile = new File(uploadPath + fName); baos = new FileOutputStream(tmpFile); bos = new BufferedOutputStream(baos); } bos.write(buffs, 0, rtnPos); baos.flush();

} else { System.out.println("test :" + value + "--" + strBuff); value = value + strBuff; } } } } catch (IOException e) { status = 4; } return status; } private int preCheck() { int errCode = 0; if ( request == null ) return 1; if ( uploadPath == null || uploadPath.trim().length() == 0 ) return 2; else{ File tmpF = new File(uploadPath); if (!tmpF.exists()) return 2; } String contentType = request.getContentType(); if ( contentType.indexOf("multipart/form-data") == -1 ) return 3; return errCode; } public String getParameter(String name){ String value = ""; if ( name == null || name.trim().length() == 0 ) return value; value = (paramHt.get(name) == null)?"":(String)((ArrayList)paramHt.get(name)).get(0); return value; } public String[] getParameters(String name){ if ( name == null || name.trim().length() == 0 ) return null; if ( paramHt.get(name) == null )

return null; ArrayList al = (ArrayList)paramHt.get(name); String[] strArr = new String[al.size()]; for ( int i=0;i

第2页/共5页 <上一页下一页>尾页

寻找更多 "JSP作业"