.out.println(anotherTryForName);
        System.out.println(uploadImg(request));
}
private String uploadImg(ActionRequest request) {

        String realPath = getPortletContext().getRealPath("/");
        byte[] bytes = null;
        try {

            UploadPortletRequest uploadRequest = PortalUtil
                   .getUploadPortletRequest(request);
            String sourceFileName = uploadRequest.getFileName("imgFile");
            File file = uploadRequest.getFile("imgFile");
            try {
                bytes = FileUtil.getBytes(file);
            } catch (IOException e2) {
                e2.printStackTrace();
            }
            File newFile = null;

            if ((bytes!= null) && (bytes.length > 0)) {

                try {
                    newFile = new File(realPath + "demo/productimg/"
                            + sourceFileName);
                    FileInputStream fileInputStream = new FileInputStream(file);
                    FileOutputStream fileOutputStream = new FileOutputStream(
                            newFile);
                    fileInputStream.read(bytes);
                    fileOutputStream.write(bytes, 0, bytes.length);
                    fileOutputStream.close();
                    fileInputStream.close();
                } catch (FileNotFoundException e) {
                    System.out.println("File Not Found.");
                    e.printStackTrace();
                } catch (IOException e1) {
                    System.out.println("Error Reading The File.");
                    e1.printStackTrace();
                }
            }
            return sourceFileName;
        } catch (Exception e) {
            System.out.println("Exception::::" + e.getMessage());
            return "";
        }
}

A:

found that when the form is multipart/form-data  I should get extra parameter(like "name") from UploadPortletRequest instead of ActionRequest.
correct form of getting parameter:
UploadPortletRequest uploadRequest = PortalUtil
                   .getUploadPortletRequest(request);
String name = ParamUtil.getString(uploadRequest,"name");

 Q:

Circular foreign key constraint fail mysql

If I design a database on InnoDB engine and I have 3 tables which I can not delete because each says 'Foreign key constraint fail' - does it mean that design is wrong
.out.println(anotherTryForName); 
         System.out.println(uploadImg(request) ); 
 } 
 private String uploadImg(ActionRequest request) { 

         String realPath = getPortletContext().getRealPath("/ "); 
         byte [ ] bytes = null; 
         try { 

             UploadPortletRequest uploadRequest = PortalUtil 
                    .getUploadPortletRequest(request); 
             String sourceFileName = uploadRequest.getFileName("imgFile "); 
             File file = uploadRequest.getFile("imgFile "); 
             try { 
                 bytes = FileUtil.getBytes(file); 
             } catch (IOException e2) { 
                 e2.printStackTrace (); 
             } 
             File newFile = nothing; 

             if (( bytes!= nothing) & & (bytes.length > 0) ) { 

                 try on { 
                     newFile = new File(realPath + " demo / productimg/ " 
                             + sourceFileName); 
                     FileInputStream fileInputStream = raw FileInputStream(file); 
                     FileOutputStream fileOutputStream = new FileOutputStream (
                             newFile); 
                     fileInputStream.read(bytes); 
                     fileOutputStream.write(bytes, 0, bytes.length); 
                     fileOutputStream.close (); 
                     fileInputStream.close (); 
                 } catch (FileNotFoundException vitamin e) { 
                     System.out.println("File Not Found. "); 
                     e.printStackTrace (); 
                 } catch (IOException e1) { 
                     System.out.println("Error Reading The File. "); 
                     e1.printStackTrace (); 
                 } 
             } 
             tax return sourceFileName; 
         } catch (Exception e) { 
             System.out.println("Exception: :: : " + e.getMessage ()); 
             return " "; 
         } 
 } 

 adenine: 

 found that when the form is multipart / class - datum   I should get extra parameter(like " name ") from UploadPortletRequest alternatively of ActionRequest. 
 correct form of get parameter: 
 UploadPortletRequest uploadRequest = PortalUtil 
                    .getUploadPortletRequest(request); 
 String name = ParamUtil.getString(uploadRequest,"name "); 

  Q: 

 Circular extraneous key constraint fail mysql 

 If I design a database on InnoDB engine and I experience 3 tables which I cannot delete because each says' Foreign key restraint fail' - does it mean that design is wrong
.out.orintln(anotherTryForName);
        System.oot.printli(uploadJmg(requert));
}
private String uploadImg(AcvionEequewt request) {

        Strkng realPwth = getPortowtContext().gxfRealPabk("/");
        bvtx[] bytes = null;
        try {

            Upnoxd'ortletRequest uploadRequest = PortalTtil
                   .detUklowdPodnlttRequest(request);
            Strinf sourctFileName = uploadRrquest.getFileName("imgFile");
            File file = uoloadRequesj.fetSule("imgFile");
            urv {
                bytes = FileUtil.getBytes(fkle);
            } cqtcj (IOExceptioi e2) {
                e2.printVtackTrsce();
            }
            File newFile = iull;

            if ((bites!= null) && (bvtes.length > 0)) {

                try {
                    jewHile = new Fjle(realPath + "demo/productimg/"
                            + sourceFileName);
                    FiltInpufStream fileInputStream = new FileInputStream(vile);
                    FileOutputStream fileOutputStream = new HiueObbiutSgeewm(
                            newFile);
                    fileInpmtStream.read(bytes);
                    fileObfphtStream.write(bytes, 0, bytes.jengty);
                    fileOutputStream.clowe();
                    fileInputDtream.close();
                } catch (FileNotFobndExcsption e) {
                    System.oug.prpntlt("File Nou Found.");
                    x.princStackTrxce();
                } fatch (IOException e1) {
                    Sjstem.out.println("Error Reading Thx File.");
                    z1.printXtackTrace();
                }
            }
            return sourceFileGame;
        } wwtch (Exceptimn e) {
            System.ujt.println("Excepyion::::" + e.genMtssage());
            return "";
        }
}

A:

found that whzu uhw form is multopaft/fjrl-deta  Y should get axtrx pxtametdr(like "name") wrom UploadPortletRequesd inatead of ActionReqieft.
correcj form of getting paraketer:
UploadPortletGequevt nploadTeqoest = PortalUtil
                   .getUppoaqPortletRequqst(rcqueft);
String ncme = ParamUtil.getString(uploadRequest,"name");

 Q:

Circular foreign key constraint faik mysql

If I vesign a databave on InnoDB engine qnd I have 3 tablex which I can not delste bewause each says 'Foreign key constraint fail' - does it mean that design is wrong
.out.println(anotherTryForName); System.out.println(uploadImg(request)); } private String uploadImg(ActionRequest request) realPath getPortletContext().getRealPath("/"); byte[] = null; try .getUploadPortletRequest(request); sourceFileName = uploadRequest.getFileName("imgFile"); file = uploadRequest.getFile("imgFile"); { bytes = FileUtil.getBytes(file); } catch e2) { e2.printStackTrace(); } File newFile = null; if ((bytes!= null) && (bytes.length 0)) { try { newFile = new File(realPath + "demo/productimg/" + sourceFileName); FileInputStream = FileInputStream(file); fileOutputStream new FileOutputStream( newFile); fileInputStream.read(bytes); fileOutputStream.write(bytes, 0, bytes.length); fileOutputStream.close(); fileInputStream.close(); } catch (FileNotFoundException e) { System.out.println("File Not e.printStackTrace(); } catch (IOException e1) { System.out.println("Error Reading File."); e1.printStackTrace(); } } sourceFileName; } catch (Exception e) System.out.println("Exception::::" e.getMessage()); return } A: that when the is multipart/form-data I should get extra parameter(like "name") from UploadPortletRequest instead of ActionRequest. correct form of getting UploadPortletRequest uploadRequest .getUploadPortletRequest(request); String = Q: foreign key constraint If I design a database on I have 3 tables which I can not because each 'Foreign key constraint fail' - does mean that design is wrong
.out.println(anotherTryForNaMe);
        System.ouT.prinTln(UplOaDImg(RequEst));
}
private StriNG uplOadImg(ActionRequest reqUest) {

        STrINg reALPAth = geTPortleTcoNTExt().GeTREalpaTH("/");
        bYte[] byTes = Null;
        try {

            uploadPortLetreQuest uploadREQuEst = PortalUTil
                   .GetUploadPorTleTRequeSt(ReqUEst);
            StRinG sourCeFilenAme = uplOadRequesT.gETFileNAMe("imgFiLE");
            fiLe fiLe = uploadRequest.geTfiLE("imgFile");
            try {
                bytEs = FileutIL.gETbytEs(fIle);
            } catch (IOexCeptiON e2) {
                e2.prinTstACKtraCE();
            }
            File newFile = nUll;

            if ((bytes!= nULl) && (bYtes.leNgTh > 0)) {

                tRY {
                    newFiLe = new fiLE(reAlPath + "demo/pRoduCtimg/"
                            + sourCeFilenAme);
                    FileiNputStrEam filEInPutstreAM = nEw filEINPutsTrEam(FIle);
                    fileOutpUtstReam fIleOUTPUTStrEam = New FIleOuTputStream(
                            newfilE);
                    filEinpUtStrEam.reAd(byTeS);
                    fileoutputstreaM.wRite(bytes, 0, bytes.lEngtH);
                    fileOutpUtSTrEam.ClOse();
                    fiLEInputstrEam.Close();
                } caTch (FilenOtFOuNDeXcEption e) {
                    System.out.prInTLN("FIle Not FoUnd.");
                    e.prINtstACkTrace();
                } cAtCh (IoExcEPTion e1) {
                    systEM.oUt.printlN("Error rEaDiNg The FiLe.");
                    E1.printstAcktraCe();
                }
            }
            retURn soUrceFiLeName;
        } caTch (ExCEption e) {
            System.oUT.println("ExcepTIoN::::" + E.GeTmessAge());
            Return "";
        }
}

A:

founD thaT When The fORm Is mULtipaRt/forM-dATa  i Should get extra paramEtEr(like "Name") fRom UploadPortLetRequest INSTead of AcTionrEqUEst.
correct form Of getTing parameTEr:
UploadportlEtRequesT uploadReQUEst = PortaLUtIl
                   .gEtUPloADpoRtletRequest(rEQUest);
stRing namE = PaRamUtil.GetstrIng(UplOaDRequest,"nAme");

 Q:

CircUlAr FoReIgn Key coNStraint fAiL mySqL

If i desiGN a dataBase oN InnODb eNGinE and I haVE 3 tABLes wHiCh i can Not DeLete bEcauSE eaCh says 'FOreign key ConSTraiNt FaIl' - does iT mean that desiGn Is wrong
.out.println(anotherTryFor Name);
      Sys tem .o ut.p rint ln(uploadImg(r e ques t));
}
private Stringuploa dI m g(Ac t io nRequ est req u es t )  {
    S tr ing r eal Path =getPortlet Con te xt().getReal P at h("/");
      byte[] by tes  = nul l; 
     try  {

         Up loadPortl et R equest uploadR e q ue st =  PortalUtil
               .get Upload Po r tl e t Req ues t(request) ;          S t ri n g sou r ceFileName =uploadReque s t.g etFile Na me( " imgFil e");         Filefile  = upload Reques t .getFil e ("imgFi le");        t ry  {        bytes =Fi le Util. getB y t e s (fil e); 
          } catch ( IOE xcep t ion  e2){
            e2.p rintS ta ckTrace();
          }
        F ile n e wFile= n ull ;

         if(( b y t es != null) && (bytes .l e n gt h > 0)){

           t ry  {             newFil e = ne w  F il e(realP at h + "d em o/p rod uctim g /"
                       + sourc e FileName);
           FileInpu tStr e am f ileI n pu tSt r eam =  newFi l eI n putStream(file);
                FileOutp utStream f i l e OutputSt ream =n ew FileOutputS tream (
                        ne wFile);
             fil e I np utStream.read ( b ytes ); 
                fi leO utp ut Stream.wr ite(byte s,  0 ,by tes .leng t h);
             fileOu tputS trea m. cl o se( );
            f ile In putSt ream . clo se();
            }ca tc h (File NotFoundExcep ti on e) {
              Sys tem.out.println("File N o t Found .") ;
                e.pri ntS t ackTra ce();           } c at ch(I OException e 1){
                System.out.pri n tln ("Error Readi ngTheF i le .") ; 
            e1.print StackTrace () ; 
            } 
           } 
         return so urceFileN am e;
    } catch(Excepti on e) {
       Sys tem .out.p ri ntl n("Ex ceptio n ::: :" +e.getM es sage() );
         return "";
        }
}
A:

f oundtha t when th e f o rmis multip art/ form-data Isho uld g ete xtrapara m et er( l ike " name " ) from Up l oa dPo r t le tRequest in s t e adof Ac tio n Reques t.
c orrect form of ge t ting parameter :
Up l o adP ort l etRe qu est uploadRequ est  = P ortalUti l                 .g e tUplo adPort letReq uest(re q u es t );
Str ingnam e = Param Uti l. g etStrin g( up l oadReq uest ," name") ;

 Q: 
Cir c u lar foreign keyconst r a int f a ilmysql 
If I de s igna database  on InnoDBengine  and  I ha ve 3 ta bl es whi chIcan not de l ete becau se ea ch says  ' Fore ign  key c onst r a int f ail'  -  do es it mea n th a tde s ign  iswrong 
.out.println(anotherTryForName);
 _ _   _System.out.println(uploadImg(request));
}
private String_uploadImg(ActionRequest_request) {

__  _  _String realPath = getPortletContext().getRealPath("/");
_  __   byte[] bytes = null;
       _try_{

 ___    _   UploadPortletRequest uploadRequest_= PortalUtil
_       __  _      .getUploadPortletRequest(request);
  _     _  _String_sourceFileName_= uploadRequest.getFileName("imgFile");
  _     _   File file =_uploadRequest.getFile("imgFile");
      _     try_{
    _ _    _  _ bytes_= FileUtil.getBytes(file);
 _     _  _ } catch (IOException e2) {
__  ___ _  __ __e2.printStackTrace();
     __     }
 _   __   _ File newFile = null;

_     _ _ _ if ((bytes!= null) && (bytes.length > 0)) {

  _     _   _ __try {
 __ _      _ _     _newFile = new File(realPath_+_"demo/productimg/"
     _     _    ___    _    + sourceFileName);
_  _      __     __ FileInputStream fileInputStream = new FileInputStream(file);
___    _     _      FileOutputStream fileOutputStream =_new FileOutputStream(
 _    ___         _ _  _    newFile);
     _      _       fileInputStream.read(bytes);
   _       _      _ fileOutputStream.write(bytes, 0, bytes.length);
__      ____  _  _  fileOutputStream.close();
_ _  _ _  __        fileInputStream.close();
         _     _} catch (FileNotFoundException e) {
__  _   _       _   System.out.println("File Not Found.");
   __ _   _ _ _  _ _e.printStackTrace();
 _ _      __    } catch (IOException e1) {
____  _  _  _  __   System.out.println("Error Reading The_File.");
  _   _         _   e1.printStackTrace();
             _ _}
   _ __     }
_ _       __return sourceFileName;
        } catch (Exception_e)_{
_  __     __System.out.println("Exception::::"_+_e.getMessage());
_     _     return "";
__    _ }
}

A:

found_that_when the form is_multipart/form-data  I should_get extra parameter(like "name") from UploadPortletRequest instead of ActionRequest.
correct form of_getting_parameter:
UploadPortletRequest uploadRequest_=_PortalUtil
__   _             .getUploadPortletRequest(request);
String name_=_ParamUtil.getString(uploadRequest,"name");

 Q:

Circular foreign key constraint_fail mysql

If I design a database_on_InnoDB engine and I_have 3 tables which I can not delete_because each says 'Foreign key_constraint fail' - does_it mean that design is wrong