JAKARTAPROJECT
JAKARTA TIPJSP TIPJSP 질문&답변DATABASE TIPJAVASCRIPT TIPWEBHACKING TIP기타 TIP
JSP 질문/답변
JSP 질문/답변
JSP 질문/답변 게시판입니다
질문은 구체적으로 해주세요 ^^
jsp 업로드하는 서블릿 소스 검토 부탁드립니다
ilovezorba
이미지 슬라이더 보기

jsp에서 파일 업로드하는 부분입니다.
제가 jsp는 잘 모르는데 다른 사람이 해 놓은것을 수정해야 합니다.
이 소스가 작은 용량의 파일은 잘 올라 가는데 용량이 큰것(약 80m)은 잘 안올라 갑니다.

서블릿으로 구동하고 있습니다.(여러가지 이유로...)

소스 전문을 올립니다.
무엇이 문제인지 아니면 어떤 부분을 점검해 봐야 하는지 등 많은 조언 부탁드립니다
벌써 3일째 헤메고 있네요 부탁드려요

 

package newebn.ucc.servlet;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URLDecoder;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import newebn.dbpool.DBConnectionMgr;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.log4j.Logger;

import newebn.ucc.domain.*;

import newebn.ucc.servlet.Encrypter;

/**
 * Servlet implementation class FileUploadServlet
 */
public class FileUploadServlet extends HttpServlet {
 Logger logger = Logger.getLogger(getClass());
 private Connection con=null;
 private PreparedStatement pstmt=null;
 private ResultSet rs=null;
 DBConnectionMgr mgr = DBConnectionMgr.getInstance();
 
 String c_Host_Id;
 private static final long serialVersionUID = 1L;
      
    /**
     * @see HttpServlet#HttpServlet()
     */
    public FileUploadServlet() {
        super();
    }

 /**
  * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
  */
 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  PrintWriter out = response.getWriter();
  HttpSession session = request.getSession();
  FileUploadListener listener = null;
  StringBuffer sb = new StringBuffer();
  long bytesRead=0;
  long contentLength=0;
  String userPkid="";
  
  if(session == null){
   return;
  }else if(session != null){
   listener = (FileUploadListener)session.getAttribute("LISTENER");
   userPkid = (String)session.getAttribute("USERPKID");
   
   if(listener == null){
    return;
   }else{
    bytesRead = listener.getBytesRead();
    contentLength = listener.getContentLength();
   }
  }

  /**
   * Response로 XML 만들기
   */

  logger.info("contentLength = " + contentLength);
  logger.info("bytesRead = " + bytesRead);

  response.setContentType("text/xml");
  sb.append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n");
  sb.append("<response>\n");
  sb.append("\t<bytes_read>" + bytesRead + "</bytes_read>\n");
  sb.append("\t<content_length>" + contentLength + "</content_length>\n");
 
  if(bytesRead == contentLength){
   sb.append("\n<finished />\n");
   
   session.setAttribute("LISTENER", null);
   session.setAttribute("USERPKID", null);
  }else{
   long percentComplete = ((100 * bytesRead) / contentLength);
   sb.append("\t<percent_complete>" + percentComplete + "</percent_complete>\n");
  }
  sb.append("\t<user_pkid>" + userPkid + "</user_pkid>\n");
  sb.append("</response>\n");
  session.setAttribute("USERPKID", null);

  out.println(sb.toString());
  out.flush();
  out.close();
 }

 /**
  * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
  */
 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  response.setContentType("text/html;charset=euc-kr");
  PrintWriter out = response.getWriter();
  final String c_PathDir      = "C:/newebn/ucc/public"; //절대경로
  final String c_Pathfolder     = "dataroom";//기본 저장 폴더 경로
  
  String conUserIdx="";    //사용자 고유값
  String conUserId="";    //로그인아이디
  String conUserName="";    //로그인이름
  String conUserLevel="";   //로그인레벨
  String conIpAddress     = request.getRemoteAddr();
  
  Cookie[] cookies2 = request.getCookies();
  if(cookies2 != null && cookies2.length > 0)
  {
   for(int i=0; i<cookies2.length; i++)
   {
    if(cookies2[i].getName().equals("MEDIA_IDX")) conUserIdx = cookies2[i].getValue();
    if(cookies2[i].getName().equals("MEDIA_ID")) conUserId = cookies2[i].getValue();
    if(cookies2[i].getName().equals("MEDIA_NAME")) conUserName = URLDecoder.decode(cookies2[i].getValue(),"euc-kr");
    if(cookies2[i].getName().equals("MEDIA_LEVEL")) conUserLevel = cookies2[i].getValue();
   }
  }

  String strMid="";
  String strUserId="";
   String strUserIdx="";
  String strCode="";
  String strPkid="";
  String strKind="";
  String strM020Pkid="";
  String strCategory="";
  String strTitle="";
  String strName="";
  String strJumin="";
  String strAddr="";
  String strTel="";
  String strEmail="";
  String strNoticeU="";
  String strAttach="";
  String strCommName1="";
  String strCommJumin1="";
  String strCommName2="";
  String strCommJumin2="";
  String strCommName3="";
  String strCommJumin3="";
  String strCommName4="";
  String strCommJumin4="";
  String strCommName5="";
  String strCommJumin5="";
  String strCommName6="";
  String strCommJumin6="";
  String strCommName7="";
  String strCommJumin7="";
  String strCommName8="";
  String strCommJumin8="";
  String strCommName9="";
  String strCommJumin9="";
  String strCommName10="";
  String strCommJumin10="";
  String strPlace="";
  String strPlan="";
  String strOption1="";
  String strOption2="";
  String strAcoment="";
  String strContent="";
  String strStatus="";
  String strFile="";
  //생년월일 변수
  String strYear="";
  String strMonth="";
  String strDay="";
  String strCommYear1="";
  String strCommMonth1="";
  String strCommDay1="";
  String strCommYear2="";
  String strCommMonth2="";
  String strCommDay2="";
  String strCommYear3="";
  String strCommMonth3="";
  String strCommDay3="";
  String strCommYear4="";
  String strCommMonth4="";
  String strCommDay4="";
  String strCommYear5="";
  String strCommMonth5="";
  String strCommDay5="";
  String strCommYear6="";
  String strCommMonth6="";
  String strCommDay6="";
  String strCommYear7="";
  String strCommMonth7="";
  String strCommDay7="";
  String strCommYear8="";
  String strCommMonth8="";
  String strCommDay8="";
  String strCommYear9="";
  String strCommMonth9="";
  String strCommDay9="";
  String strCommYear10="";
  String strCommMonth10="";
  String strCommDay10="";
  //성별 변수
  String strSex="";
  String strCommSex1="";
  String strCommSex2="";
  String strCommSex3="";
  String strCommSex4="";
  String strCommSex5="";
  String strCommSex6="";
  String strCommSex7="";
  String strCommSex8="";
  String strCommSex9="";
  String strCommSex10="";

  boolean fileFlag=false;
  //String strPath = c_PathDir + "/" + c_Pathfolder + "/";
  String strPath = "//58.225.10.93/media/UCC/";
  //String strPath2 = c_Pathfolder + "/";
  String strPath2 = "";
  SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHmmss");
  String strFormat = sf.format(new Date());
  strPath += strFormat;
  strPath2 += strFormat;
  String strUploadFileNm="";
  String FileWholdPath="";
  int strPkid2=0;
  int maxNum=0;
  boolean flag=true;
  
  int maxSize = 10*1024*1024*800;
  
  String name="";
  String value="";
  String strSql="";
  
  FileItemFactory factory = new DiskFileItemFactory();
  ServletFileUpload upload = new ServletFileUpload(factory);
  
  FileUploadListener listener = new FileUploadListener();
  
  HttpSession session = request.getSession();
  session.setAttribute("LISTENER", listener);
  
  upload.setSizeMax(maxSize);
  upload.setProgressListener(listener);
  
  List uploadItems=null;
  FileItem fileItem=null;
  try{
   if(request.getContentLength() > upload.getSizeMax()){
    uploadItems = upload.parseRequest(request);
    Iterator i = uploadItems.iterator();
    while(i.hasNext()){
     fileItem = (FileItem)i.next();
     if(fileItem.isFormField()){
      name = fileItem.getFieldName();
      value = fileItem.getString("euc-kr");
      
      if(name.equals("p_status")) strStatus=value;
      if(name.equals("p_mid")) strMid=value;
      if(name.equals("p_userId")) strUserId=value;
      if(name.equals("p_userIdx")) strUserIdx=value;
      if(name.equals("p_code")) strCode=value;
      if(name.equals("p_M020Pkid")) strM020Pkid=value;
      if(name.equals("p_pkid")) strPkid=value;
      if(name.equals("p_kind")) strKind=value;
      if(name.equals("p_title")) strTitle=value;
      if(name.equals("p_name")) strName=value;
      if(name.equals("p_jumin")) strJumin=value;
      if(name.equals("p_addr")) strAddr=value;
      if(name.equals("p_tel")) strTel=value;
      if(name.equals("p_email")) strEmail=value;
      if(name.equals("p_attach")) strAttach=value;
      if(name.equals("p_comm_name1")) strCommName1=value;
      if(name.equals("p_comm_jumin1")) strCommJumin1=value;
      if(name.equals("p_comm_name2")) strCommName2=value;
      if(name.equals("p_comm_jumin2")) strCommJumin2=value;
      if(name.equals("p_comm_name3")) strCommName3=value;
      if(name.equals("p_comm_jumin3")) strCommJumin3=value;
      if(name.equals("p_comm_name4")) strCommName4=value;
      if(name.equals("p_comm_jumin4")) strCommJumin4=value;
      if(name.equals("p_comm_name5")) strCommName5=value;
      if(name.equals("p_comm_jumin5")) strCommJumin5=value;
      if(name.equals("p_comm_name6")) strCommName6=value;
      if(name.equals("p_comm_jumin6")) strCommJumin6=value;
      if(name.equals("p_comm_name7")) strCommName7=value;
      if(name.equals("p_comm_jumin7")) strCommJumin7=value;
      if(name.equals("p_comm_name8")) strCommName8=value;
      if(name.equals("p_comm_jumin8")) strCommJumin8=value;
      if(name.equals("p_comm_name9")) strCommName9=value;
      if(name.equals("p_comm_jumin9")) strCommJumin9=value;
      if(name.equals("p_comm_name10")) strCommName10=value;
      if(name.equals("p_comm_jumin10")) strCommJumin10=value;
      if(name.equals("p_place")) strPlace=value;
      if(name.equals("p_plan")) strPlan=value;
      if(name.equals("p_content")) strContent=value;
      if(name.equals("p_aComent")) strAcoment=value;
      if(name.equals("p_year")) strYear=value;
      if(name.equals("p_month")) strMonth=value;
      if(name.equals("p_day")) strDay=value;
      if(name.equals("p_comm_year1")) strCommYear1=value;
      if(name.equals("p_comm_month1")) strCommMonth1=value;
      if(name.equals("p_comm_day1")) strCommDay1=value;
      if(name.equals("p_comm_year2")) strCommYear2=value;
      if(name.equals("p_comm_month2")) strCommMonth2=value;
      if(name.equals("p_comm_day2")) strCommDay2=value;
      if(name.equals("p_comm_year3")) strCommYear3=value;
      if(name.equals("p_comm_month3")) strCommMonth3=value;
      if(name.equals("p_comm_day3")) strCommDay3=value;
      if(name.equals("p_comm_year4")) strCommYear4=value;
      if(name.equals("p_comm_month4")) strCommMonth4=value;
      if(name.equals("p_comm_day4")) strCommDay4=value;
      if(name.equals("p_comm_year5")) strCommYear5=value;
      if(name.equals("p_comm_month5")) strCommMonth5=value;
      if(name.equals("p_comm_day5")) strCommDay5=value;
      if(name.equals("p_comm_year6")) strCommYear6=value;
      if(name.equals("p_comm_month6")) strCommMonth6=value;
      if(name.equals("p_comm_day6")) strCommDay6=value;
      if(name.equals("p_comm_year7")) strCommYear7=value;
      if(name.equals("p_comm_month7")) strCommMonth7=value;
      if(name.equals("p_comm_day7")) strCommDay7=value;
      if(name.equals("p_comm_year8")) strCommYear8=value;
      if(name.equals("p_comm_month8")) strCommMonth8=value;
      if(name.equals("p_comm_day8")) strCommDay8=value;
      if(name.equals("p_comm_year9")) strCommYear9=value;
      if(name.equals("p_comm_month9")) strCommMonth9=value;
      if(name.equals("p_comm_day9")) strCommDay9=value;
      if(name.equals("p_comm_year10")) strCommYear10=value;
      if(name.equals("p_comm_month10")) strCommMonth10=value;
      if(name.equals("p_comm_day10")) strCommDay10=value;
      if(name.equals("p_sex")) strSex=value;
      if(name.equals("p_comm_sex1")) strCommSex1=value;
      if(name.equals("p_comm_sex2")) strCommSex2=value;
      if(name.equals("p_comm_sex3")) strCommSex3=value;
      if(name.equals("p_comm_sex4")) strCommSex4=value;
      if(name.equals("p_comm_sex5")) strCommSex5=value;
      if(name.equals("p_comm_sex6")) strCommSex6=value;
      if(name.equals("p_comm_sex7")) strCommSex7=value;
      if(name.equals("p_comm_sex8")) strCommSex8=value;
      if(name.equals("p_comm_sex9")) strCommSex9=value;
      if(name.equals("p_comm_sex10")) strCommSex10=value;
     }else{
      if(fileItem.getSize() > 0){
       File uploadFile=null;
       int indexOf = fileItem.getName().lastIndexOf("\\");
       if(indexOf == -1){
        indexOf = fileItem.getName().lastIndexOf("/");
       }
       strFile = fileItem.getName().substring(indexOf+1);
       
       if(!GetMovieFile(strFile)){
        ExecJavaAlert("동영상 파일이 아닙니다.",0,out);
       }else{
        ExecFolderMake(strPath);
        strUploadFileNm = strFile;
        strUploadFileNm = strUploadFileNm.replace(" ","");
        strUploadFileNm = strUploadFileNm.replace("'","");
        
        FileWholdPath = GetUniqueName(strUploadFileNm, strPath);
        if(FileWholdPath != null && !FileWholdPath.equals("")){
        uploadFile = new File(FileWholdPath);
        fileItem.write(uploadFile);
        fileFlag = true;
        }
       }
      }
     }
    }

    //파일명 공백 제거
    strFile = strFile.replaceAll(" ","");
    //strFile = strFile.replaceAll("&","&amp;");

    strJumin = strYear+"-"+strMonth+"-"+strDay;
    if(NullCheck(strCommYear1) && NullCheck(strCommMonth1) && NullCheck(strCommDay1))
     strCommJumin1 = strCommYear1+"-"+strCommMonth1+"-"+strCommDay1;
    if(NullCheck(strCommYear2) && NullCheck(strCommMonth2) && NullCheck(strCommDay2))
     strCommJumin2 = strCommYear2+"-"+strCommMonth2+"-"+strCommDay2;
    if(NullCheck(strCommYear3) && NullCheck(strCommMonth3) && NullCheck(strCommDay3))
     strCommJumin3 = strCommYear3+"-"+strCommMonth3+"-"+strCommDay3;
    if(NullCheck(strCommYear4) && NullCheck(strCommMonth4) && NullCheck(strCommDay4))
     strCommJumin4 = strCommYear4+"-"+strCommMonth4+"-"+strCommDay4;
    if(NullCheck(strCommYear5) && NullCheck(strCommMonth5) && NullCheck(strCommDay5))
     strCommJumin5 = strCommYear5+"-"+strCommMonth5+"-"+strCommDay5;
    if(NullCheck(strCommYear6) && NullCheck(strCommMonth6) && NullCheck(strCommDay6))
     strCommJumin6 = strCommYear6+"-"+strCommMonth6+"-"+strCommDay6;
    if(NullCheck(strCommYear7) && NullCheck(strCommMonth7) && NullCheck(strCommDay7))
     strCommJumin7 = strCommYear7+"-"+strCommMonth7+"-"+strCommDay7;
    if(NullCheck(strCommYear8) && NullCheck(strCommMonth8) && NullCheck(strCommDay8))
     strCommJumin8 = strCommYear8+"-"+strCommMonth8+"-"+strCommDay8;
    if(NullCheck(strCommYear9) && NullCheck(strCommMonth9) && NullCheck(strCommDay9))
     strCommJumin9 = strCommYear9+"-"+strCommMonth9+"-"+strCommDay9;
    if(NullCheck(strCommYear10) && NullCheck(strCommMonth10) && NullCheck(strCommDay10))
     strCommJumin10 = strCommYear10+"-"+strCommMonth10+"-"+strCommDay10;

    Encrypter enc = new Encrypter();

    strName = enc.returnEncryptCode(strName);
    strJumin = enc.returnEncryptCode(strJumin);
    strAddr = enc.returnEncryptCode(strAddr);
    strTel = enc.returnEncryptCode(strTel);
    strEmail = enc.returnEncryptCode(strEmail);
    strAttach = enc.returnEncryptCode(strAttach);
    if(NullCheck(strCommName1)) strCommName1 = enc.returnEncryptCode(strCommName1);
    if(NullCheck(strCommJumin1)) strCommJumin1 = enc.returnEncryptCode(strCommJumin1);
    if(NullCheck(strCommName2)) strCommName2 = enc.returnEncryptCode(strCommName2);
    if(NullCheck(strCommJumin2)) strCommJumin2 = enc.returnEncryptCode(strCommJumin2);
    if(NullCheck(strCommName3)) strCommName3 = enc.returnEncryptCode(strCommName3);
    if(NullCheck(strCommJumin3)) strCommJumin3 = enc.returnEncryptCode(strCommJumin3);
    if(NullCheck(strCommName4)) strCommName4 = enc.returnEncryptCode(strCommName4);
    if(NullCheck(strCommJumin4)) strCommJumin4 = enc.returnEncryptCode(strCommJumin4);
    if(NullCheck(strCommName5)) strCommName5 = enc.returnEncryptCode(strCommName5);
    if(NullCheck(strCommJumin5)) strCommJumin5 = enc.returnEncryptCode(strCommJumin5);
    if(NullCheck(strCommName6)) strCommName6 = enc.returnEncryptCode(strCommName6);
    if(NullCheck(strCommJumin6)) strCommJumin6 = enc.returnEncryptCode(strCommJumin6);
    if(NullCheck(strCommName7)) strCommName7 = enc.returnEncryptCode(strCommName7);
    if(NullCheck(strCommJumin7)) strCommJumin7 = enc.returnEncryptCode(strCommJumin7);
    if(NullCheck(strCommName8)) strCommName8 = enc.returnEncryptCode(strCommName8);
    if(NullCheck(strCommJumin8)) strCommJumin8 = enc.returnEncryptCode(strCommJumin8);
    if(NullCheck(strCommName9)) strCommName9 = enc.returnEncryptCode(strCommName9);
    if(NullCheck(strCommJumin9)) strCommJumin9 = enc.returnEncryptCode(strCommJumin9);
    if(NullCheck(strCommName10)) strCommName10 = enc.returnEncryptCode(strCommName10);
    if(NullCheck(strCommJumin10)) strCommJumin10 = enc.returnEncryptCode(strCommJumin10);

    bbsHost(strMid,response.getWriter());
    
    if(strStatus == null || strStatus.equals(""))
     strStatus="1";
     
    con = mgr.getConnection();
    strSql="";
    strSql = "SELECT ISNULL(max(B030_PKID), 0) FROM BOD060TL";
    try {
     pstmt = con.prepareStatement(strSql);
     rs = pstmt.executeQuery();
     if(rs.next())
     {
      maxNum = rs.getInt(1)+1;
     }
    } catch (SQLException e) {
     e.printStackTrace();
    } finally {
     if(rs!=null) try{ rs.close(); }catch(SQLException e){}
     if(pstmt!=null) try{ pstmt.close(); }catch(SQLException e){}
     if(con!=null)
     {
      mgr.freeConnection();
      try{ con.close(); }catch(SQLException e){}
     }
    }
    
    if(strCode.equals("edit") || strCode.equals("del"))
     strPkid2 = Integer.parseInt(strPkid);
    else
     strPkid2 = maxNum;

    session.setAttribute("USERPKID",Integer.toString(strPkid2));
    
    if(strCode.equals("edit") || strCode.equals("del")){
     String oldFile="";
     String oldPath=c_PathDir + "/";
     
     con = mgr.getConnection();
     strSql="";
     strSql="SELECT B030_FILE,B030_PATH FROM BOD060TL WHERE B030_PKID=?";
     try{
      pstmt = con.prepareStatement(strSql);
      pstmt.setInt(1,strPkid2);
      
      rs = pstmt.executeQuery();
      if(rs.next()){
       oldFile = rs.getString("B030_FILE");
       oldPath += rs.getString("B030_PATH");
       
       ExecFileDelete(oldPath, oldFile);
      }
     }catch(SQLException e){
      e.printStackTrace();
     }
    }
    
    if(strCode.equals("add")){
     if(fileFlag){
      if(strUserIdx == null || strUserIdx.equals("")){
       strUserIdx = "2";
       strUserId = "guest";
      }
      
      con = mgr.getConnection();
      strSql="";
      strSql="INSERT INTO BOD060TL(";
      strSql+="B030_PKID,B030_B010_PKID,B030_MENU_ID,";
      strSql+="B030_CATEGORY,B030_TITLE,B030_USER_ID,";
      strSql+="B030_NAME,B030_EMAIL,B030_NOTICE_U,";
      strSql+="B030_READNUM,B030_FILE,B030_PATH,";
      strSql+="B030_DOWN_NUM,B030_COMMENT_NUM,B030_VOTE_NUM,";
      strSql+="B030_OPTION1,B030_OPTION2,B030_CONTENT,";
      strSql+="B030_PLACE,B030_PLAN,B030_ACOMENT,";
      strSql+="B030_EMP_ID,B030_STATUS,B030_KIND,B030_IP_ADDRESS,B030_M010_IDX,";
      strSql+="B030_CATAL_ACTION,B030_TRANS_ACTION,B030_PROGRESS";
      strSql+=")VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,'q','q',0)";
      if(strCategory == null || strCategory.equals("")) strCategory="공모전";
   
      try{
       pstmt = con.prepareStatement(strSql);
       pstmt.setInt(1,strPkid2);
       pstmt.setString(2,c_Host_Id);
       pstmt.setString(3,strMid);
       pstmt.setString(4,strCategory);
       pstmt.setString(5,strTitle);
       pstmt.setString(6,strUserId);
       pstmt.setString(7,strName);
       pstmt.setString(8,strEmail);
       pstmt.setString(9,strNoticeU);
       pstmt.setInt(10,0);
       pstmt.setString(11,strFile);
       pstmt.setString(12,strPath2);
       pstmt.setInt(13,0);
       pstmt.setInt(14,0);
       pstmt.setInt(15,0);
       pstmt.setString(16,strOption1);
       pstmt.setString(17,strOption2);
       pstmt.setString(18,strContent);
       pstmt.setString(19,strPlace);
       pstmt.setString(20,strPlan);
       pstmt.setString(21,strAcoment);
       pstmt.setString(22,conUserId);
       pstmt.setString(23,strStatus);
       pstmt.setString(24,strKind);
       pstmt.setString(25,conIpAddress);
       pstmt.setInt(26,Integer.parseInt(strUserIdx));
       
       pstmt.execute();
       
       flag=true;
      }catch(SQLException e){
       e.printStackTrace();
       flag=false;
      }finally{
       if(flag){
        strSql="";
        strSql = "SELECT ISNULL(max(M020_PKID), 0) FROM MEM020TL";
        try {
         pstmt = con.prepareStatement(strSql);
         rs = pstmt.executeQuery();
         if(rs.next())
         {
          maxNum = rs.getInt(1)+1;
         }
        } catch (SQLException e) {
         e.printStackTrace();
        }
        
        strSql="";
        strSql="INSERT INTO MEM020TL(";
        strSql+="M020_PKID,M020_M010_PKID,M020_B030_PKID,";
        strSql+="M020_C020_PKID,M020_TITLE,M020_NAME,";
        strSql+="M020_JUMIN,M020_ADDRESS,M020_TEL,";
        strSql+="M020_EMAIL,M020_ATTACH,M020_COMM_NAME1,";
        strSql+="M020_COMM_JUMIN1,M020_COMM_NAME2,M020_COMM_JUMIN2,";
        strSql+="M020_COMM_NAME3,M020_COMM_JUMIN3,";
        strSql+="M020_COMM_NAME4,M020_COMM_JUMIN4,";
        strSql+="M020_COMM_NAME5,M020_COMM_JUMIN5,";
        strSql+="M020_COMM_NAME6,M020_COMM_JUMIN6,";
        strSql+="M020_COMM_NAME7,M020_COMM_JUMIN7,";
        strSql+="M020_COMM_NAME8,M020_COMM_JUMIN8,";
        strSql+="M020_COMM_NAME9,M020_COMM_JUMIN9,";
        strSql+="M020_COMM_NAME10,M020_COMM_JUMIN10,";
        strSql+="M020_SEX,M020_COMM_SEX1,M020_COMM_SEX2,M020_COMM_SEX3,M020_COMM_SEX4,M020_COMM_SEX5,M020_COMM_SEX6,M020_COMM_SEX7,M020_COMM_SEX8,M020_COMM_SEX9,M020_COMM_SEX10";
        strSql+=")VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        
        try{
         pstmt = con.prepareStatement(strSql);
         pstmt.setInt(1, maxNum);
         pstmt.setInt(2,Integer.parseInt(strUserIdx));
         pstmt.setInt(3,strPkid2);
         pstmt.setString(4,"E00001");
         pstmt.setString(5,strTitle);
         pstmt.setString(6,strName);
         pstmt.setString(7,strJumin);
         pstmt.setString(8,strAddr);
         pstmt.setString(9,strTel);
         pstmt.setString(10,strEmail);
         pstmt.setString(11,strAttach);
         pstmt.setString(12,strCommName1);
         pstmt.setString(13,strCommJumin1);
         pstmt.setString(14,strCommName2);
         pstmt.setString(15,strCommJumin2);
         pstmt.setString(16,strCommName3);
         pstmt.setString(17,strCommJumin3);
         pstmt.setString(18,strCommName4);
         pstmt.setString(19,strCommJumin4);
         pstmt.setString(20,strCommName5);
         pstmt.setString(21,strCommJumin5);
         pstmt.setString(22,strCommName6);
         pstmt.setString(23,strCommJumin6);
         pstmt.setString(24,strCommName7);
         pstmt.setString(25,strCommJumin7);
         pstmt.setString(26,strCommName8);
         pstmt.setString(27,strCommJumin8);
         pstmt.setString(28,strCommName9);
         pstmt.setString(29,strCommJumin9);
         pstmt.setString(30,strCommName10);
         pstmt.setString(31,strCommJumin10);
         pstmt.setString(32,strSex);
         pstmt.setString(33,strCommSex1);
         pstmt.setString(34,strCommSex2);
         pstmt.setString(35,strCommSex3);
         pstmt.setString(36,strCommSex4);
         pstmt.setString(37,strCommSex5);
         pstmt.setString(38,strCommSex6);
         pstmt.setString(39,strCommSex7);
         pstmt.setString(40,strCommSex8);
         pstmt.setString(41,strCommSex9);
         pstmt.setString(42,strCommSex10);
         
         pstmt.execute();
        }catch(SQLException e){
         e.printStackTrace();
        }finally{
         if(pstmt!=null) try{ pstmt.close(); }catch(SQLException e){}
         if(con!=null)
         {
          mgr.freeConnection();
          try{ con.close(); }catch(SQLException e){}
         } 
        }
       }else{
        if(pstmt!=null) try{ pstmt.close(); }catch(SQLException e){}
        if(con!=null)
        {
         mgr.freeConnection();
         try{ con.close(); }catch(SQLException e){}
        }
       }
      }
     }
    }else if(strCode.equals("edit")){
     if(strUserId == null || strUserId.equals("")) strUserId = "guest";
     if(strUserIdx == null || strUserIdx.equals("")) strUserIdx = "2";
     if(strCategory == null || strCategory.equals("")) strCategory="공모전";
     
     strSql="";
     strSql="UPDATE BOD060TL SET ";
     strSql+="B030_CATEGORY=?,B030_TITLE=?,B030_USER_ID=?,";
     strSql+="B030_NAME=?,B030_EMAIL=?,B030_NOTICE_U=?,";
     strSql+="B030_FILE=?,B030_PATH=?,B030_OPTION1=?,";
     strSql+="B030_OPTION2=?,B030_CONTENT=?,B030_PLACE=?,";
     strSql+="B030_PLAN=?,B030_ACOMENT=?,B030_EMP_ID=?,";
     strSql+="B030_STATUS=?,B030_KIND=?,B030_IP_ADDRESS=?,B030_M010_IDX=?";
     strSql+=" WHERE B030_PKID=?";

     try{
      pstmt = con.prepareStatement(strSql);
      pstmt.setString(1,strCategory);
      pstmt.setString(2,strTitle);
      pstmt.setString(3,strUserId);
      pstmt.setString(4,strName);
      pstmt.setString(5,strEmail);
      pstmt.setString(6,strNoticeU);
      pstmt.setString(7,strFile);
      pstmt.setString(8,strPath2);
      pstmt.setString(9,strOption1);
      pstmt.setString(10,strOption2);
      pstmt.setString(11,strContent);
      pstmt.setString(12,strPlace);
      pstmt.setString(13,strPlan);
      pstmt.setString(14,strAcoment);
      pstmt.setString(15,conUserId);
      pstmt.setString(16,strStatus);
      pstmt.setString(17,strKind);
      pstmt.setString(18,conIpAddress);
      pstmt.setInt(19,Integer.parseInt(strUserIdx));
      pstmt.setInt(20,strPkid2);
      
      pstmt.executeUpdate();
      flag=true;
     }catch(SQLException e){
      System.out.println("B030UPDATE = " + e);
      e.printStackTrace();
      flag=false;
     }finally{
      if(flag){
       strSql="";
       strSql="UPDATE MEM020TL SET ";
       strSql+="M020_TITLE=?,M020_NAME=?,M020_JUMIN=?,";
       strSql+="M020_ADDRESS=?,M020_TEL=?,M020_EMAIL=?,";
       strSql+="M020_ATTACH=?,M020_COMM_NAME1=?,M020_COMM_JUMIN1=?,";
       strSql+="M020_COMM_NAME2=?,M020_COMM_JUMIN2=?,M020_COMM_NAME3=?,";
       strSql+="M020_COMM_JUMIN3=? ";
       strSql+="M020_COMM_NAME4=?,M020_COMM_JUMIN4=?, ";
       strSql+="M020_COMM_NAME5=?,M020_COMM_JUMIN5=?, ";
       strSql+="M020_COMM_NAME6=?,M020_COMM_JUMIN6=?, ";
       strSql+="M020_COMM_NAME7=?,M020_COMM_JUMIN7=?, ";
       strSql+="M020_COMM_NAME8=?,M020_COMM_JUMIN8=?, ";
       strSql+="M020_COMM_NAME9=?,M020_COMM_JUMIN9=?, ";
       strSql+="M020_COMM_NAME10=?,M020_COMM_JUMIN10=?, ";
       strSql+="M020_SEX=?, ";
       strSql+="M020_COMM_SEX1=?, ";
       strSql+="M020_COMM_SEX2=?, ";
       strSql+="M020_COMM_SEX3=?, ";
       strSql+="M020_COMM_SEX4=?, ";
       strSql+="M020_COMM_SEX5=?, ";
       strSql+="M020_COMM_SEX6=?, ";
       strSql+="M020_COMM_SEX7=?, ";
       strSql+="M020_COMM_SEX8=?, ";
       strSql+="M020_COMM_SEX9=?, ";
       strSql+="M020_COMM_SEX10=? ";
       strSql+=" WHERE M020_PKID=?";
       
       try{
        pstmt = con.prepareStatement(strSql);
        pstmt.setString(1,strTitle);
        pstmt.setString(2,strName);
        pstmt.setString(3,strJumin);
        pstmt.setString(4,strAddr);
        pstmt.setString(5,strTel);
        pstmt.setString(6,strEmail);
        pstmt.setString(7,strAttach);
        pstmt.setString(8,strCommName1);
        pstmt.setString(9,strCommJumin1);
        pstmt.setString(10,strCommName2);
        pstmt.setString(11,strCommJumin2);
        pstmt.setString(12,strCommName3);
        pstmt.setString(13,strCommJumin3);
        pstmt.setString(14,strCommJumin4);
        pstmt.setString(15,strCommJumin5);
        pstmt.setString(16,strCommJumin6);
        pstmt.setString(17,strCommJumin7);
        pstmt.setString(18,strCommJumin8);
        pstmt.setString(19,strCommJumin9);
        pstmt.setString(20,strCommJumin10);
        pstmt.setString(21,strSex);
        pstmt.setString(22,strCommSex1);
        pstmt.setString(23,strCommSex2);
        pstmt.setString(24,strCommSex3);
        pstmt.setString(25,strCommSex4);
        pstmt.setString(26,strCommSex5);
        pstmt.setString(27,strCommSex6);
        pstmt.setString(28,strCommSex7);
        pstmt.setString(29,strCommSex8);
        pstmt.setString(30,strCommSex9);
        pstmt.setString(31,strCommSex10);
        pstmt.setInt(32,Integer.parseInt(strM020Pkid));
        
        pstmt.executeUpdate();
        flag=true;
       }catch(SQLException e){
        System.out.println("M020UPDATE = " + e);
        e.printStackTrace();
        flag=false;
       }finally{
        if(pstmt!=null) try{ pstmt.close(); }catch(SQLException e){}
        if(con!=null)
        {
         mgr.freeConnection();
         try{ con.close(); }catch(SQLException e){}
        } 
       }
      }else{
       if(pstmt!=null) try{ pstmt.close(); }catch(SQLException e){}
       if(con!=null)
       {
        mgr.freeConnection();
        try{ con.close(); }catch(SQLException e){}
       }
      }
     }
    }else if(strCode.equals("del")){
     con = mgr.getConnection();
     strSql="";
     strSql="DELETE FROM BOD060TL WHERE B030_PKID=?";
     
     try{
      pstmt = con.prepareStatement(strSql);
      pstmt.setInt(1,strPkid2);
      
      pstmt.executeUpdate();
      flag=true;
     }catch(SQLException e){
      e.printStackTrace();
      flag=false;
     }finally{
      if(pstmt!=null) try{ pstmt.close(); }catch(SQLException e){}
      if(con!=null){
       mgr.freeConnection();
       try{ con.close(); }catch(SQLException e){}
      }
     }
    }
    //out.write("strMid = " + strMid);
    //out.write("c_Host_Id = " + c_Host_Id);
    //if(true) return;
    if(flag){
     ExecJavaAlert2("업로드가 완료되었습니다",0,out);
     //ExecJavaAlertLocation("업로드가 완료되었습니다.변환작업페이지로 이동합니다.","/board/active2.jsp?p_mbs=05-01&p_mid="+strMid+"p_pkid="+strPkid2,out);
    }else{
     ExecJavaAlert("알수 없는 에러가 발생 하였습니다.관리자에게 문의해 주세요.",0,out);
    }
    
   }else{
    ExecJavaAlert("업로드 용량 초과입니다.",0,out);
   }
  }catch(FileUploadException e){
   e.printStackTrace();
   logger.info("FileUploadExecption : " + e);
  }catch(Exception e){
   e.printStackTrace();
   logger.info("Exception : " + e);
  }
 }
 
 public void bbsHost(String n,PrintWriter out)
 {
  Connection con;
  PreparedStatement pstmt;
  ResultSet rs;
  DBConnectionMgr mgr = DBConnectionMgr.getInstance();
  
  con = mgr.getConnection();
  String strSql = "SELECT * FROM BOD010TL ";
  strSql += "WHERE B010_MENU_ID=?";
  
  try{
   pstmt = con.prepareStatement(strSql);
   pstmt.setString(1, n);
   
   rs = pstmt.executeQuery();
   if(rs.next())
   {
    //호스트 필드
    c_Host_Id =   rs.getString("B010_PKID");
   }
   else
   {
    ExecJavaAlert("일치하는 호스트가없습니다.",0,out);
   }
  }catch(SQLException e){
   e.printStackTrace();
  }
 }
 
////***************************************************************************************
////* 함수설명 : 업로드 파일 동영상 여부 확인 *
////* 변수설명 : strFileName = 업로드 파일명 *
 ////***************************************************************************************
 public boolean GetMovieFile(String strFileName)
 {
  String strFileExt="";
  boolean flag=false;
  int indexOf = strFileName.lastIndexOf('.');
  strFileExt = strFileName.substring(indexOf+1).toUpperCase(); //소문자 대문자로 변경
  if(strFileExt.equals("mp4") || strFileExt.equals("MP4") || strFileExt.equals("wmv") || strFileExt.equals("WMV") || strFileExt.equals("mov") || strFileExt.equals("MOV") || strFileExt.equals("avi") || strFileExt.equals("AVI") || strFileExt.equals("flv") || strFileExt.equals("FLV"))
   flag=true;
  else
   flag=false;
  
  return flag;
 }
 
 ////***************************************************************************************
////* 함수설명 : 자바스크립트 메세지창 출력후 이동 *
////* 변수설명 : str,strUrl = 메세지명 , 이동할주소 *
 ////***************************************************************************************
 public void ExecJavaAlertLocation(String strMsg,String strUrl,PrintWriter out)
 {
  out.println("<script language='javascript'>");
  out.println("<!--");
  out.println("alert('"+strMsg+"');");
  out.println("self.location='"+strUrl+"';");
  out.println("//-->");
  out.print("</script>");
 }
 
 ////***************************************************************************************
//// * 함수설명 : 폴더 생성 *
//// * 변수설명 : strPath = 생성할 폴더 경로 및 폴더명 *
 //// ***************************************************************************************
 public void ExecFolderMake(String strPath)
 {
  String FSO;
  String fldr;
  File file = new File(strPath);
  if(!file.exists())
  {
   file.mkdirs();
  }
 }
 
 ///// 유니크한 파일경로및 파일이름을 얻어내는 함수
 public String GetUniqueName(String strFileName, String DirectoryPath)
 {
  //확장자를 제외한 파일명을 얻는다.
  int indexOf = strFileName.lastIndexOf('.');
  String strName=strFileName.substring(0, indexOf);
  String strExt=strFileName.substring(indexOf+1);
  
  boolean bExist=true;
  //우선 같은이름의 파일이 존재한다고 가정
  String strFileWhloePath=DirectoryPath + "/" + strName + "." + strExt;
  //저장할 파일의 완전한 이름(완전한 물리적인 경로) 구성
  int countFileName = 0;
  File file = new File(strFileWhloePath);
  
  while(bExist) //우선 있다고 생각함.
  {
   if(file.exists()) // 같은 이름의 파일이 있을 때
   {
    countFileName++; //파일명에 숫자를 붙인 새로운 파일 이름 생성
    strFileName = strName + "(" + countFileName + ")." + strExt;
    strFileWhloePath = DirectoryPath + "/" + strFileName;
    file = new File(strFileWhloePath);
   }
   else
   {
    bExist=false;
   }
   System.out.println(bExist);
  }
  
  return strFileWhloePath;
 }
 
 ////***************************************************************************************
////* 함수설명 : 파일삭제 함수 *
////* 변수설명 : strPath : 삭제할 파일의 경로 *
////* strFileName : 삭제할 파일의 이름 *
 ////***************************************************************************************
 public void ExecFileDelete(String strPath, String strFileName)
 {
  File file = new File(strPath, strFileName);
  if(file.exists())
  {
   file.delete();
  }
 }
 
 ////***************************************************************************************
////* 함수설명 : 자바스크립트 메시지 출력 *
////* 변수설명 : strMsg = 출력메시지 *
////* strExec = 스크립트 처리 (0:이전화면 / 1:창닫기) *
 ////***************************************************************************************
 public void ExecJavaAlert(String strMsg,int strExec,PrintWriter out)
 {
  String str="";
  str = "<script language='javascript'>";
  str += "alert('"+strMsg+"');";
  if(strExec == 0)
   str += "history.go(-1);";
  else
   str += "self.close();";
  
  str += "</script>";
  out.print(str);
 }

 public void ExecJavaAlert2(String strMsg,int strExec,PrintWriter out)
 {
  String str="";
  str = "<script language='javascript'>";
  str += "alert('"+strMsg+"');";
 }

 public boolean NullCheck(String strData)
 {
  boolean flag=false;

  if(strData != null && !strData.equals("") && !strData.equals("null"))
   flag=true;
  else
   flag=false;

  return flag;
 }
}

2010-09-30 14:12:00
203.236.222.***
따봉 조또 종합 0 (0명)
덧글 1개 | 태그 1개 | 관련글보기
태그입력
쉽표(,)구분으로 한번에 여러 태그를 입력할수 있습니다
jsp suvlet ajax (1)
GoodBug
(0) (0)

소스상에선 별다른점은 안보이고요..

 

로컬에서 테스트할 때는 대용량 파일도 잘 되는데, 서버에 올려서 테스트해봐서 잘 안된다면

해당 웹서버에서 어느정도 용량을 허용하는지 확인해 보세요

보통 용량이 큰 파일인 경우 웹서버 설정에 의해 차단되는 경우가 있습니다

 

210.94.41.*** 2010-09-30 14:12:00
이름 비밀번호
JSP 질문/답변
JSP 질문/답변 게시판입니다
질문은 구체적으로 해주세요 ^^
! 번호 제목 글쓴이 일자 조회
1154 일정 시간 후 다른 페이지로 점프하는 것을 어떻게 하나요 java로요. 최윤석 2016-01-31 698
1153 질문 드립니다. 선처를 부탁 드려요.ㅠㅠ 에뮬올 2014-11-12 1,239
1152 FTP 파일 다운로드 질문드립니다. 잠팅 2014-09-04 1,231
1151 jsp-> xml 문서 출력관련 질문입니다~ 월영인 2013-04-02 2,042
1150 이미지 FTPclient로 업로드시 이미지 깨짐현상 1 2 그러려니해 2013-01-30 5,103
1149 자바 기초와 변수와 자료형. 에이치비아이 2012-07-30 2,293
1148 로그인 관련 프링글스! 2012-06-21 2,355
1147 개발자 버전 다운로드 관련 1 풍경소리 2011-09-01 2,790
1146 자바빈으로 ODBC 연결하는 방법 두루오이 2011-06-09 3,585
1145 廣告: 三月의 이메일알바는 banana-mails 입니다.@ bargs 2011-03-01 4,223
1144 자바스크립트 소트질문드려요.. 1 터줏대감 2010-11-09 4,940
1143 jsp 첨 접하는데요 $_PHPSELF 같이럼 쓸수없는가요? dosman 2010-10-25 4,641
jsp suvlet ajax jsp 업로드하는 서블릿 소스 검토 부탁드립니다 1 1 ilovezorba 2010-09-17 4,320
1141 1 1z 2010-09-09 4,295
1140 서버 셋팅시 한글깨짐 질문 입니다. 슈팅스타 2010-09-02 5,085
1139 FTP CopyStreamException 오류 해결 방법 알려주세요 ㅠ 1 크크 2010-08-01 10,255
1138 파일 타입 체크 test 2010-07-12 4,854
1137 페이징 질문. 1 음.. 2010-06-30 4,481
1136 파일명및 확장자를 변경한 이미지를 보여주기 1 nob 2010-06-11 5,192
1135 플래시하고 jsp링크하는거 질문 드립니다..ㅠㅠ 1 tjarhks 2010-06-10 5,449
copyright 2005-2018 by Unicorn