ABAP-HR  WAGES UPLOADING PROBLEM

Hi experts,
i am using HR_INFOTYPE_OPERATION function module to upload wages.
While inserting operation only one record itself inserted. If i am giving more than one wage type for a single infotype it will be over writted.   Pls help me to do thisl
My code is ..
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0008'
number = P0008-PERNR
SUBTYPE =
OBJECTID =
LOCKINDICATOR =
validityend = p0008-ENDDA
validitybegin = p0008-BEGDA
RECORDNUMBER =
record = p0008
operation = 'MOD'
TCLAS = 'A'
DIALOG_MODE = '0'
NOCOMMIT =
VIEW_IDENTIFIER =
SECONDARY_RECORD =
IMPORTING
return = G_return
key = infty_key
Regards,
Murugan Arumugam

Hi Murugan,
     For infotype 0008 we can upload 20 wage types and its amount for single record. If you look at infotype 0008 we have fields LGA01, BET01, LGA02, BET02….. LGA20, BET20.
In function module 'HR_INFOTYPE_OPERATION' you have exporting filed record which you passed p0008. In structure p0008 you have fields LGA01, BET01, LGA02, BET02….. LGA20, BET20. Here you need to pass the values first wage type to lga01 and its amount to bet01 and second wage type to lga02 and its amount bet02 then execute the function module.
If you have any doubts please let me know.

Similar Messages

  • Need a fix for Muse upload problems to GoDaddy????  I found one!

    GoDaddy now has a new cpanel named "Plesk".  In that panel you will find File Manager.  (I use the Windows version).  In the left panel of File Manager, you will see the root directory and all of its subfolders.  When you click on any of these folders, you will see their contents in the right panel.  You will also see a folder labelled "httpdocs".  This is the default folder that is set up in GoDaddy to be your "home" folder.  So, to fix your upload problems, do these steps:
    1.  Click on the httpdocs folder to see it open in the right panel.  In the toolbar above the right panel, you will see a green plus sign with the word "New".  Click on this drop-down menu.
    2.  Choose "directory"
    3.  Type in the name of one of the folders that your site will need, e.g. images, css, assets, scripts, etc.  This basically creates a subfolder within the httpdocs folder, right?  (There is a way to see how your Muse site sets up these folders prior to publish or upload.  You do this by choosing "Export as HTML" in the File menu of Muse, creating a folder on your desktop (or wherever) for the HTML export, then inspecting its contents after your save it.)
    4.  Continue to create all the subfolders within httpdocs that you will need.  Unfortunately, you have to do this one folder at a time.
    5.  After you have them set up, begin the process of uploading your site, like this:
    6.  In the File menu in Muse, you'll of course see "Upload to FTP Host ...".  Click on it.
    7.  A dialog box will open.  In the top text field, type in your website name ... you must use www. with your entry
    8.  In the "FTP Host" field, type in your domain name again like this ... "ftp.yourdomain.com" ... NO FORWARD SLASHES!!! (even if you find instructions to the contrary, like in Filezilla)  (Also, your domain might be a .org or .net, instead of a .com)
    9.  In the "Host directory" field, YOU MUST ENTER "httpdocs"!!!!  Despite what you learn, DO NOT LEAVE THIS FIELD BLANK!!!
    10.  Then enter your GoDaddy username and password.  (If you set up a different username for your GoDaddy account and your Plesk account, like I did, then use your Plesk username and password.)
    11.  Click on "Upload:  All Files"
    The next few steps are tedious, but necessary to keep your site organized on GoDaddy and to keep from confusing things.  You can probably get away with it, but, if your site doesn't load properly in a browser after doing the above steps, you'll need to click on each folder in the root directory that you copied as a subfolder in the "httpdocs" folder and delete the files.  For example, in the left panel of File Manager, you'll see the root directory.  Click on the "images" folder.  If there are any images that you need for your site in that folder, delete them.  Remember ... you've already copied them over to the images subfolder in httpdocs during your last upload described in the instructions above.  If you don't trust that you can delete them, click on the "httpdocs" folder, then click on the "images" folder and check the files.  Same files, right?  So, go ahead and delete the site files that you find in the appropriate folders in the root directory, making sure that you don't delete the ones that are NOT duplicated within the "httpdocs" folder.  Also remember that your .html pages will not require a subfolder to be set up in the "httpsdocs" folder.  They can just sit there, looking pretty.  But you will have to delete them from the root directory to keep things tidy.  Just click on the folder icon next to "root directory", and you'll see those html pages in the right panel.  Again, delete them. 
    REMEMBER:  To keep your Muse uploads to your GoDaddy site error free, you must ALWAYS make sure that "httpdocs" appears in the "Host directory" field in the "Upload to FTP Host ..." dialog box in Muse.  And all files and folders that your site needs MUST go in the "httpdocs" folder in the root directory of your site in GoDaddy's File Manager (now found in your Plesk Panel).
    I hope this wasn't too confusing.  If so, call GoDaddy.  I called them with this fix and they are using it in their phone support.

    Thank you! Thank you! Thank you! I was going out of my mind. And GoDaddy was no help (although they're usually really good.) I put all the folders in "httpdocs" and the website worked perfectly!

  • A different uploading problem

    I have read through the discussions and see that a lot of people are having an uploading problem. I am too, but my problem is a little different. When I upload my photos, everything seems to be fine, all the pages turn from blue to red, and it appears to be done. But, if I quit iWeb, it says it hasn't finished uploading. When I go to the site on the web, everything is there. So, it seems to not be finalizing the last little part where it marks the files as uploaded.
    I am using iWeb 1.1.1.
    I have tried deleting the files from my iDisk and uploading again.
    I have repaired permissions.
    I have deleted the file com.apple.iWeb.plist
    It's not that I'm trying to quit too soon, I have left it for hours, even overnight, and it doesn't complete.
    There's a small circle to the right of the word site that fills in to show progress as it's finishing, and that gets to the point where there's only a small sliver of white.
    Any ideas? Thanks for the help!
    Kirsten
    MacBook   Mac OS X (10.4.7)  

    Have you tried "Publish ALL to .Mac"?

  • Uploading problem with Ebay and Dreamweaver MX

    I am unable to sync websites with Dreamweaver MX 6.01. When I connect to the remote server, it shuts down the program. I have reinstalled the program, but it still does it. Also, when I use Safari, Opera, and Firefox to upload photos on Ebay, the upload process fails completely, and blows me directly into My Ebay, as if I was not on the selling page at all. I have to go to my PC to do the photo uploads. Seems like it may be a related issue, some kind of uploading problem with Rosetta, or something. I am using a Macbook Pro with the 2.0Ghz processor, connected with ethernet cable, and firewall is set to off. Any ideas?

    For E-Bay you might try the following:
    Type the following command in Terminal (while Safari is NOT running):
    defaults write com.apple.Safari IncludeDebugMenu 1
    Then launch Safari, and you will be able to use the new Debug menu.
    If you ever wish to disable it again, just repeat the command with a "0" instead of a "1".
    Under the Debug menu, you'll see the User Agent sub-menu; select Windows MSIE 6.0 from the list and then try connecting to your web site
    Dreamweaver you might need to update your version.
    To Dreamweaver 8.01
    http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=f56452a8

  • Uploading problems with Safari 4.1.3 -

    Hello, I just thought this was a funny question to ask -
    On my PowerPC G5 tower, running OS 10.4.11, and my question is in regards to Safari version 4.1.3 uploading problems for facebook and youtube... I always have to use FireFox version 3.6.13... and not without trouble either.
    I get it.  I need a new computer, but I just thought it fascinating why one works 90% of the time and the other never works.

    Firefox is way more upto date than Safari in 10.4.11, but TenFourFox is the most up to date browser for our PPCs, they even have G4 & G5 optimized versions...
    http://www.floodgap.com/software/tenfourfox/
    Also I think they Require Flash &/or Java, which may be a problem in 10.4

  • Is Safari the problem?  upload problems after Leopard install...

    I installed maximum ram and leopard 10.5 on my old emac and it runs great. I had problems uploading photos to ebay, and attachments to emails, so I installed ilife hoping the upgrade would fix the problem. Nope, when I attempt to upload, the icon just spins and spins, on and on. Could this be a Safari problem? Very frustrated, totally stumped.

    I'm not sure how to link to the iPhoto post thread that help me solve my upload problem. But it is solved. I had to resize the jpeg pic files to 640x320 because my files were way to big. Thanks Old Toad!

  • Web Dynpro ABAP - File upload Problem (Timeout)

    Hello Experts,
    we are facing an issue with a custom WD Abap application:
    We use the file upload UI element in order to store PDF files within our system. For 90% of our users it works perfectly.
    However, for some users an error occurs: Once they select the file at their local system and press "upload", the system is loading and loading and eventually it ends up as a time out.
    We have checked the browser settings and permissions. But everything looks good.
    We are running on:
    SAP_BASIS 731 0013
    Does anybody know a solution for this problem?
    Thanks for your help!
    Maximilian

    Hi Maximillian,
    Please check the following notes,if they are applicable to you.
    1912687 - IE11: File Upload not working
    1818772 - WDA: Performance issue for file upload
    Regards,
    Harsha

  • Material Master upload problem (LSMW)

    Hi
      I am using Standard Batch input program (RMDATIND)  for MM upload i need to validate the old material number if it is already existed in MARA it should throw an error at the end of the processing saying that "Old material number" already existing in MARA . Flat file will have thousands of records.
    One solution like, we can move all the error records in one internal table in code of Filed mapping conversion rule step , but the problem is where we can write the error records?
    Another question when we use Standard program for conversion is it possible to show error log at the end of the processing?
    Its very urgent  Kindly help me ........
    Rgds,
    bhanu.......

    Hi,
      YOu can populate error messages in LSMW. To achieve this you add code in LSMW.  Follow the below procedure to add code in LSMW.
    In Display FieldMapping and Conversion rule Step of LSMW click the button Display Variant. A screen will pop up. Check the boxes - Global Definitions and ABAP Sub Programs. This will allow you to add code in LSMW.
    At check the error records follow the below mentioned procedure...
    <b>Error messages in the conversion log</b>
    How can user-defined error messages be added to the conversion log?
    1.     Use of  WRITE  command in the Coding
    a.     Example: WRITE: ‚Error during conversion of field xxx’
    2.     In the editor use ‚Insert -> Message’ to use a message already existing in the SAP system.
    a.     Example (Coding after using the menu function and filling the fields):
    WA_ERRORTAB-ID = '/SAPDMC/LSMW'.
    WA_ERRORTAB-MSGNO = 012.                         
    WA_ERRORTAB-PAR1 = 'A'.                          
    WA_ERRORTAB-PAR2 = 'B'.                          
    WA_ERRORTAB-PAR3 = 'C'.                          
    WA_ERRORTAB-PAR4 = 'D'.                          
    INSERT WA_ERRORTAB INTO TABLE G_ERROR_TAB. 
    The message will be added to the log.
    For further reference click the link below
    http://www.erpgenie.com/sapgenie/docs/Lsmw.zip.
    Regards,
    Vara

  • IGS COnverted BMP Image upload problem in SE78

    HI Friends,
    I Converted the JPEG image into BMP ormat by using IGS. It is converting properly. i am able to see the BMP image. When i am trying to upload it through the SE78 i am getting the short dump.
    If convert it manually, i am able to upload the image. i did not get the any difference between these two including file size, width and height.
    I attached the shortdump and converted image file as an attachment. Can anyone give me inputs where i am missing the target.
    Runtime error : COMPUTE_INT_TIMES_OVERFLOW
    Exception : CX_SY_ARITHMETIC_OVERFLOW
    Thanks ,
    Srinivas Bhavanam

    Hi Oisin,
    Sorry for the Late Reply. I am using IGS 6.40 with solaris system.
    If i am converting the image from my desktop i am getting 96DPI resolution. Where as if i am doing it from IGS i am getting 30682172 DPI resolution.
    I am using SAP 4.7. Is it the latest patch level or latest IGS supported.
    Short Dump :
    Runtime Error          COMPUTE_INT_TIMES_OVERFLOW
    Exception              CX_SY_ARITHMETIC_OVERFLOW
           Occurred on     03.03.2010 at   11:04:30
    Whole number overflow on multiplication.
    What happened?
    Error in ABAP application program.
    The current ABAP program "SAPLSTXBITMAPS" had to be terminated because one of
    the
    statements could not be executed.
    This is probably due to an error in the ABAP program.
    What can you do?
    Print out the error message (using the "Print" function)
    and make a note of the actions and input that caused the
    error.
    To resolve the problem, contact your SAP system administrator.
    You can use transaction ST22 (ABAP Dump Analysis) to view and administer
    termination messages, especially those beyond their normal deletion
    date.
    Error analysis
    An exception occurred. This exception is dealt with in more detail below
    . The exception, which is assigned to the class 'CX_SY_ARITHMETIC_OVERFLOW',
    was neither
    caught nor passed along using a RAISING clause, in the procedure
    "FILL_BMFILE_FROM_BMP" "(FORM)"
    Since the caller of the procedure could not have expected this exception
    to occur, the running program was terminated.
    The reason for the exception is:
    In the current program "SAPLSTXBITMAPS", multiplying the numbers 1207959552 and
    100 (using the operation * or 'MULTIPLY') resulted in a value
    greater than 2147483647 or smaller than -2147483648. This
    results in a whole number overflow.
    How to correct the error
    The exception must either be prevented, caught within the procedure
    "FILL_BMFILE_FROM_BMP"
    "(FORM)", or declared in the procedure's RAISING clause.
    To prevent the exception, note the following:
    You may be able to split the process into separate components, so that
    the values generated are smaller.
    If the error occurred in one of your own programs or in an SAP program
    that you modified, try to correct it yourself.
    If you cannot solve the problem yourself, please send the
    following documents to SAP:
    1. A hard copy print describing the problem.
       To obtain this, select the "Print" function on the current screen.
    2. A suitable hardcopy prinout of the system log.
       To obtain this, call the system log with Transaction SM21
       and select the "Print" function to print out the relevant
       part.
    3. If the programs are your own programs or modified SAP programs,
       supply the source code.
       To do this, you can either use the "PRINT" command in the editor or
       print the programs using the report RSINCL00.
    4. Details regarding the conditions under which the error occurred
       or which actions and input led to the error.
    System environment
    SAP Release.............. "620"
    Application server....... "EWR0R3DEV002"
    Network address.......... "10.20.32.13"
    Operating system......... "SunOS"
    Release.................. "5.9"
    Hardware type............ "sun4u"
    Character length......... 16 Bits
    Pointer length........... 64 Bits
    Work process number...... 0
    Short dump setting....... "full"
    Database server.......... "EWR0R3DEV002"
    Database type............ "ORACLE"
    Database name............ "I07"
    Database owner........... "SAPRGG"
    Character set............ "C"
    SAP kernel............... "640"
    Created on............... "Mar 9 2009 21:04:19"
    Created in............... "SunOS 5.8 Generic_117350-38 sun4u"
    Database version......... "OCI_920 "
    Patch level.............. "274"
    Patch text............... " "
    Supported environment....
    Database................. "ORACLE 9.2.0.., ORACLE 10.1.0.., ORACLE
    10.2.0.."
    SAP database version..... "640"
    Operating system......... "SunOS 5.8, SunOS 5.9, SunOS 5.10"
    User, transaction...
    Client.............. 999
    User................ "SREDDY"
    Language key........ "E"
    Transaction......... "SE78 "
    Program............. "SAPLSTXBITMAPS"
    Screen.............. "SAPLSTXBITMAPS 4001"
    Screen line......... 8
    Information on where terminated
    The termination occurred in the ABAP program "SAPLSTXBITMAPS" in
    "FILL_BMFILE_FROM_BMP".
    The main program was "SAPMSSCH ".
    The termination occurred in line 1959 of the source code of the (Include)
    program "LSTXBITMAPSF03"
    of the source code of program "LSTXBITMAPSF03" (when calling the editor 19590).
    Processing was terminated because the exception "CX_SY_ARITHMETIC_OVERFLOW"
    occurred in the
    procedure "FILL_BMFILE_FROM_BMP" "(FORM)" but was not handled locally, not
    declared in the
    RAISING clause of the procedure.
    The procedure is in the program "SAPLSTXBITMAPS ". Its source code starts in
    line 1843
    of the (Include) program "LSTXBITMAPSF03 ".
    Source code extract
    019290     endcase.
    019300   * compression
    019310     perform bmptab_getdword_ofs tables bitmap_file
    019320                                 using  ofs bmp_compression.
    019330     case bmp_compression.
    019340       when c_bmp_compr_rgb.              "BI_RGB, uncompressed
    019350       when c_bmp_compr_rle8. "BI_RLE8, 256 colors colormap, rle encoding
    019360       when c_bmp_compr_rle4. "BI_RLE8, 16 colors colormap, rle encoding
    019370       when others. message e872 raising bmperr_unsup_compression.
    019380     endcase.
    019390   * size of image
    019400     perform bmptab_getdword_ofs tables bitmap_file
    019410                                 using  ofs bmp_sizeimage.
    019420   * pix per meter X
    019430     perform bmptab_getlong_ofs tables bitmap_file
    019440                             using ofs bmp_xpelspermeter.
    019450   * pix per meter Y
    019460     perform bmptab_getlong_ofs tables bitmap_file
    019470                             using ofs bmp_ypelspermeter.
    019480   * colors used
    019490     perform bmptab_getdword_ofs tables bitmap_file
    019500                                 using  ofs word.
    019510   * colors important
    019520     perform bmptab_getdword_ofs tables bitmap_file
    019530                                 using  ofs word.
    019540     ofs_rgbquad = ofs_bitmapinfoheader + bmp_bisize.
    019550   * now we have OFS_RGBQUAD    -> color table
    019560   *             OFS_BITMAPDATA -> bitmap bytes
    019570     otf_bminfo-new_rd_format = c_false.
    019580     otf_bminfo-is_resident   = c_false.
    >     otf_bminfo-dpi = ( bmp_xpelspermeter * 100 ) / 3937.
    019600     perform bmp_adjust_dpi using otf_bminfo-dpi.
    019610     otf_bminfo-w_pix = bmp_width.
    019620     otf_bminfo-h_pix = abs( bmp_height ).
    019630     otf_bminfo-w_tw = ( 1440 * otf_bminfo-w_pix ) / otf_bminfo-dpi.
    019640     otf_bminfo-h_tw = ( 1440 * otf_bminfo-h_pix ) / otf_bminfo-dpi.
    019650     case bmp_bitcount.
    019660       when 1.
    019670         otf_bminfo-bitsperpix = 1.
    019680         otf_bminfo-bytes_per_row = otf_bminfo-w_pix div 8.
    019690         rest = otf_bminfo-w_pix mod 8.
    019700       when 4.
    019710         otf_bminfo-bitsperpix = 4.
    019720         otf_bminfo-bytes_per_row = otf_bminfo-w_pix div 2.
    019730         rest = otf_bminfo-w_pix mod 2.
    019740       when 8.
    019750         otf_bminfo-bitsperpix = 8.
    019760         otf_bminfo-bytes_per_row = otf_bminfo-w_pix.
    019770         rest = 0.
    019780       when 24.
    Thanks & Regards,
    Srinivas Bhavanam

  • OBN upload problem

    Hi Experts,
    I have a strange problem.
    When I upload a role from the backend system (with a abap webdynpro iview) the OBN are saved in the PCD under the Logical system name. (Business Objects/com.sap.portal.migrated/Logical system name). When I start the iview in the role the OBN is called with the system alias name, and then I get the message:
    Error message " failed to solve Object Based Navigation target '<system alias>.<OBN name>.<action>. Contact your system administrator to assign a role to your user with the relevant OBN entries'.
    When I check the OBN in the role (open the OBN under Business Objects/com.sap.portal.migrated/Logical system name choose ' Object-Based Navigation', select the Business Object and choose ' Locates in Portal Catalog. it's pointing to the OBN in the PCD. under Business Objects/com.sap.portal.migrated/Logical system name. 
    In the iview I changed the the properties for 'com.sap.portal.pm.parameters', 'System' and 'Target System', with the Logical system name, cleared the caches, but problem still exist.
    How to solve this?
    Thanks in advance,
    Vo.

    Dear Etay,
    Please check the document: How to Upload Backend Roles to SAP Netweaver Portal
    Please ensure that all the steps are followed.
      > 5.5 OBN – Object Based Navigation
    Best Regards,
    Rajendra

  • FILE UPLOAD PROBLEM SHOWING THE CONTENTS IN THE SAME BROWSER WINDOW

    Hi,
    This is amit Joshi
    I have uploaded content using input tag of type file and posted to jsp as multipart/form-data type
    in that jsp i am using following code to display the content in browser but only first content is displayed How can i modify it to show all content in the file ..
    <html>
    <head>
    <title>File Upload Display</title>
    </head>
    <body>
    <%
    //ServletOutputStream sout=response.getOutputStream();
    StringBuilder strBuilder = new StringBuilder();
    int count=0;
    String f;
    f=request.getParameter("filedb");
    DBManager dbm = new DBManager();
    //dbm.createTable("mms3");
    //log.info("In JSP : "+ f);
    //dbm.insert_data(f,"mms3");
    %>
    <%
    if (ServletFileUpload.isMultipartContent(request)){
    ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
    List fileItemsList = servletFileUpload.parseRequest(request);
    strBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>").append('\r').append('\n').append("<xpage version=\"1.0\">").append('\r').append('\n');
    String optionalFileName = "";
    FileItem fileItem = null;
    Iterator it = fileItemsList.iterator();
    ServletOutputStream outputStream=null;
    while (it.hasNext()){
    FileItem fileItemTemp = (FileItem)it.next();
    if (fileItemTemp.isFormField()){
    %>
    <b>Name-value Pair Info:</b>
    Field name: <%= fileItemTemp.getFieldName() %>
    Field value: <%= fileItemTemp.getString() %>
    <%
    if (fileItemTemp.getFieldName().equals("filename"))
    optionalFileName = fileItemTemp.getString();
    else
    fileItem = fileItemTemp;
    if (fileItem!=null){
    String fileName = fileItem.getName();
    %>
    <b>Uploaded File Info:</b>
    Content type: <%= fileItem.getContentType() %>
    Field name: <%= fileItem.getFieldName() %>
    File name: <%= fileName %>
    <%
    if(fileItem.getContentType().equals("image/jpeg")) { %>
    File : <p><%
         //response.setContentType("image/gif");
         byte[] bArray=fileItem.get();
         response.setContentType("image/jpeg");
         outputStream=null;
         outputStream= response.getOutputStream();
         outputStream.write(bArray);
         outputStream.flush();
         outputStream.close();
    else if(fileItem.getContentType().equals("text/plain"))
         %> File : <%= fileItem.getString() %>
    <%
    byte[] bArray=fileItem.get();
    response.setContentType("text/plain");
         outputStream = response.getOutputStream();
         out.println();
         outputStream.write(bArray);
         outputStream.flush();
         outputStream.close();
    %> </p> <%
    %>
    </body>
    </html>
    Edited by: Amit_Joshi on Nov 13, 2007 10:58 PM

    Well Well Well..
    That would not work...
    What you have to do is save the uploaded file content on to a location and then pass the fileName as a request parameter to a deidicated which displays the contents of that file.
    Just as an example
    <html>
    <head>
    <title>File Upload Display</title>
    </head>
    <body>
    <%
    //ServletOutputStream sout=response.getOutputStream();
    StringBuilder strBuilder = new StringBuilder();
    int count=0;
    String f;
    f=request.getParameter("filedb");
    DBManager dbm = new DBManager();
    //dbm.createTable("mms3");
    //log.info("In JSP : "+ f);
    //dbm.insert_data(f,"mms3");
    %>
    <%
    if (ServletFileUpload.isMultipartContent(request)){
    ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
    List fileItemsList = servletFileUpload.parseRequest(request);
    strBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>").append('\r').append('\n').append("<xpage version=\"1.0\">").append('\r').append('\n');
    String optionalFileName = "";
    FileItem fileItem = null;
    Iterator it = fileItemsList.iterator();
    ServletOutputStream outputStream=null;
    while (it.hasNext()){
       FileItem fileItemTemp = (FileItem)it.next();
    %>
    Name-value Pair Info:
    Field name: <%= fileItemTemp.getFieldName() %><br/>
    Field value: <%= fileItemTemp.getString() %><br/>
    <%
    if (fileItemTemp.getFieldName().equals("filename"))
        optionalFileName = fileItemTemp.getString();
    if(!fileTempItem.isFormFiled()){
       String fileName = fileItem.getName();
       fileItem.write(optionalFileName);
    %>
    Uploaded File Info:
    Content type: <%= fileItem.getContentType() %><br/>
    Field name: <%= fileItem.getFieldName() %><br/>
    File name: <%= fileName %><br/>
    <%
    if(fileItem.getContentType().equals("image/jpeg") || fileItem.getContentType().equals("image/pjeg")) {
    %>
      <img src="FileServlet?fileName=<%=optionalFileName%>"   
    <%
    %>
    </body>
    </html>a sample code snippet for FileServlet.
    String fileName =  request.getParameter(fileName);
      File file = new File(fileName);
       if(!file.exists())
         return;
      // If JSP
      String mimeType = application.getMimeType("fileName");
           If you are using servlet
           String mimeType = this.getServletContext().getMimeType(fileName);
         response.setContentType(mimeType);  
         response.setHeader("Content-Disposition","inline;filename=\\"+fileName+"\\");
      BufferedOutputStream out1 = null;
      InputStream in = null;
      if(mimeType == null)
         mimeType = "application/octet-stream";
      try{
         in = new FileInputStream(f);
         response.setContentLength(in.available());
         BufferedOutputStream out1 = new BufferedOutputStream(response.getOutputStream(),1024);
         int size = 0;
         byte[] b = new byte[1024];
         while ((size = in.read(b, 0, 1024)) > 0)
            out1.write(b, 0, size);
      }catch(Exception exp){
      }finally{
          if(out1 != null){
             try{
                out1.flush();               
                out1.close();
             }catch(Exception e){}
          if(in != null){
            try{in.close();}catch(Exception e){}
      } Hope that might answer your question :)
    However,this is not the recommended way of doing this make use of MVC pattern.Would be a better approach.
    you might think of googling on this and can findout what is the best practise followed for problems of this sort
    REGARDS,
    RaHuL

  • Help with ftp upload problem

    Hi I am using a ftp class (known as FTPConnection) that i found on this site: http://www.nsftools.com/tips/JavaFtp.htm , and they only have an example of how to download a File through FTP and not upload one. I am in the proccess of making an FTP upload applet, and need some help on getting upload to work. I also need it to work on both a Pc and mac, so that may be attributing to the problem becuase i am currently on a mac which uses file:// instead of C:\\. Ill post the ftp class, and a snippet of my code that tries to upload a selected file.
    FTPConnection
    /* <!-- in case someone opens this in a browser... --> <pre> */
    * File:   FTPConnection.java
    * Author: Bret Taylor <[email protected]>
    * URL: http://www.stanford.edu/~bstaylor/cs/ftpconnection/FTPConnection.java.shtml
    * see also <a href="http://www.nsftools.com/tips/JavaFtp.htm">http://www.nsftools.com/tips/JavaFtp.htm</a>
    * $Id$
    * Parts of this code were adopted from a variety of other FTP classes the
    * author has encountered that he was not completely satisfied with.  If you
    * think more thanks are due to any particular author than is given, please
    * let him know.  With that caveat, this class can be freely distributed and
    * modified as long as Bret Taylor is given credit in the source code comments.
    * Modified by Julian Robichaux -- http://www.nsftools.com
    * Added constructors, logout(), listFiles(), listSubdirectories(), getAndParseDirList(),
    * processFileListCommand(), and overloaded getFullServerReply().
    * Also added StringBuffer parameter options to transferData() and executeDataCommand()
    * and did a few other little things.
    import java.io.*;
    import java.net.*;
    import java.util.*;
    * <p>A wrapper for the network and command protocols needed for the most common
    * FTP commands.  Standard usage looks something like this:</p>
    * <pre> FTPConnection connection = new FTPConnection();
    * try {
    *     if (connection.connect(host)) {
    *         if (connection.login(username, password)) {
    *             connection.downloadFile(serverFileName);
    *             connection.uploadFile(localFileName);
    *         connection.disconnect();
    * } catch (UnknownHostException e) {
    *     // handle unknown host
    * } catch (IOException e) {
    *     // handle I/O exception
    * }</pre>
    * <p>Most FTP commands are wrapped by easy-to-use methods, but in case clients
    * need more flexibility, you can execute commands directly using the methods
    * <a href="#executeCommand(java.lang.String)">executeCommand</a> and
    * <a href="#executeDataCommand(java.lang.String,
    * java.io.OutputStream)">executeDataCommand</a>,
    * the latter of which is used for commands that require an open data port.</p>
    * @author Bret Taylor
    * @author Julian Robichaux
    * @version 1.01
    public class FTPConnection extends Object {
         * If this flag is on, we print out debugging information to stdout during
         * execution.  Useful for debugging the FTP class and seeing the server's
         * responses directly.
        private static boolean PRINT_DEBUG_INFO = false;
         * The socket through which we are connected to the FTP server.
        private Socket connectionSocket = null;
         private String username;
         private String password;
         private String host;
         * The socket output stream.
        private PrintStream outputStream = null;
         * The socket input stream.
        private BufferedReader inputStream = null;
         * The offset at which we resume a file transfer.
        private long restartPoint = 0L;
         * Added by Julian: If this flag is on, we're currently logged in to something.
        private boolean loggedIn = false;
         * Added by Julian: This is the line terminator to use for multi-line responses.
        public String lineTerm = "\n";
         * Added by Julian: This is the size of the data blocks we use for transferring
         * files.
        private static int BLOCK_SIZE = 4096;
         * Added by Julian: After you create an FTPConnection object, you will call the
         * connect() and login() methods to access your server. Please don't forget to
         * logout() and disconnect() when you're done (it's only polite...).
        public FTPConnection ()
             // default constructor (obviously) -- this is just good to have...
         * Added by Julian: Allows you to specify if you want to send debug output to
         * the console (true if you do, false if you don't).
        public FTPConnection (boolean debugOut)
             PRINT_DEBUG_INFO = debugOut;
         public FTPConnection (String user, String pw, String host_)
             username=user;
              password=pw;
              host=host_;
              PRINT_DEBUG_INFO = false;
         * Prints debugging information to stdout if the private flag
         * <code>PRINT_DEBUG_INFO</code> is turned on.
        private void debugPrint(String message) {
            if (PRINT_DEBUG_INFO) System.err.println(message);
         * Connects to the given FTP host on port f, the default FTP port.
        public boolean connect(String host)
            throws UnknownHostException, IOException
            return connect(host, 21);
         * Connects to the given FTP host on the given port.
        public boolean connect(String host, int port)
            throws UnknownHostException, IOException
            connectionSocket = new Socket(host, port);
              connectionSocket.setSoTimeout(10000);
            outputStream = new PrintStream(connectionSocket.getOutputStream());
            inputStream = new BufferedReader(new
                           InputStreamReader(connectionSocket.getInputStream()));
            if (!isPositiveCompleteResponse(getServerReply())){
                disconnect();
                return false;
            return true;
         * Disconnects from the host to which we are currently connected.
         static boolean URLexists(String URLName)
              try
                   HttpURLConnection.setFollowRedirects(false);
                   // note : you may also need
                   // HttpURLConnection.setInstanceFollowRedirects(false)
                   HttpURLConnection con =
                   (HttpURLConnection) new URL(URLName).openConnection();
                   con.setRequestMethod("HEAD");
                   return (con.getResponseCode() == HttpURLConnection.HTTP_OK);
              catch (Exception e)
                   e.printStackTrace();
                   return false;
         public String getSimpleFileName(File f)
              String path=f.getPath();
              String fileName=path.replace("\\", "/");
              int slashPos = fileName.lastIndexOf("/");
              fileName=fileName.substring(slashPos+1);
              return fileName;
         public String verifyFileName(String name)
              int count=0;
              //String url="http://chris-malcolm.com/images/"+URLEncoder.encode(name).replace("+", "%20");
              while (URLexists("http://chris-malcolm.com/images/"+URLEncoder.encode(name).replace("+", "%20"))==true)
              count++;
              name=FileExt(name)[0]+"-"+count+"."+FileExt(name)[1];
              return name;
         public String[] FileExt(String fileName)
            int dotPos = fileName.lastIndexOf(".");
              fileName=fileName.replace("\\", "/");
              int slashPos = fileName.lastIndexOf("/");
              String extension, name;
              if (slashPos==fileName.length()-1)
                   fileName=fileName.substring(0, fileName.length()-1);
                   slashPos=fileName.lastIndexOf("/");
                   extension="/";
                   name=fileName.substring(slashPos+1);
              else if(dotPos==-1)
                   name=fileName.substring(slashPos+1);
                   extension="";
              else
                   extension = fileName.substring(dotPos+1);
                   name=fileName.substring(slashPos+1, dotPos);
                   String[] output={name, extension};
                   return output;
              String[] output={name, extension};
              return output;
        public void disconnect()
            if (outputStream != null) {
                try {
                      if (loggedIn) { logout(); };
                    outputStream.close();
                    inputStream.close();
                    connectionSocket.close();
                } catch (IOException e) {}
                outputStream = null;
                inputStream = null;
                connectionSocket = null;
         * Wrapper for the commands <code>user [username]</code> and <code>pass
         * [password]</code>.
        public boolean login(String username, String password)
            throws IOException
            int response = executeCommand("user " + username);
            if (!isPositiveIntermediateResponse(response)) return false;
            response = executeCommand("pass " + password);
            loggedIn = isPositiveCompleteResponse(response);
            return loggedIn;
         * Added by Julian: Logout before you disconnect (this is good form).
        public boolean logout()
            throws IOException
            int response = executeCommand("quit");
            loggedIn = !isPositiveCompleteResponse(response);
            return !loggedIn;
         * Wrapper for the command <code>cwd [directory]</code>.
        public boolean changeDirectory(String directory)
            throws IOException
            int response = executeCommand("cwd " + directory);
            return isPositiveCompleteResponse(response);
         * Wrapper for the commands <code>rnfr [oldName]</code> and <code>rnto
         * [newName]</code>.
        public boolean renameFile(String oldName, String newName)
            throws IOException
            int response = executeCommand("rnfr " + oldName);
            if (!isPositiveIntermediateResponse(response)) return false;
            response = executeCommand("rnto " + newName);
            return isPositiveCompleteResponse(response);
         * Wrapper for the command <code>mkd [directory]</code>.
        public boolean makeDirectory(String directory)
            throws IOException
            int response = executeCommand("mkd " + directory);
            return isPositiveCompleteResponse(response);
         * Wrapper for the command <code>rmd [directory]</code>.
        public boolean removeDirectory(String directory)
            throws IOException
            int response = executeCommand("rmd " + directory);
            return isPositiveCompleteResponse(response);
         * Wrapper for the command <code>cdup</code>.
        public boolean parentDirectory()
            throws IOException
            int response = executeCommand("cdup");
            return isPositiveCompleteResponse(response);
         * Wrapper for the command <code>dele [fileName]</code>.
        public boolean deleteFile(String fileName)
            throws IOException
            int response = executeCommand("dele " + fileName);
            return isPositiveCompleteResponse(response);
         * Wrapper for the command <code>pwd</code>.
        public String getCurrentDirectory()
            throws IOException
            String response = getExecutionResponse("pwd");
            StringTokenizer strtok = new StringTokenizer(response);
            // Get rid of the first token, which is the return code
            if (strtok.countTokens() < 2) return null;
            strtok.nextToken();
            String directoryName = strtok.nextToken();
            // Most servers surround the directory name with quotation marks
            int strlen = directoryName.length();
            if (strlen == 0) return null;
            if (directoryName.charAt(0) == '\"') {
                directoryName = directoryName.substring(1);
                strlen--;
            if (directoryName.charAt(strlen - 1) == '\"')
                return directoryName.substring(0, strlen - 1);
            return directoryName;
         * Wrapper for the command <code>syst</code>.
        public String getSystemType()
            throws IOException
            return excludeCode(getExecutionResponse("syst"));
         * Wrapper for the command <code>mdtm [fileName]</code>.  If the file does
         * not exist, we return -1;
        public long getModificationTime(String fileName)
            throws IOException
            String response = excludeCode(getExecutionResponse("mdtm " + fileName));
            try {
                return Long.parseLong(response);
            } catch (Exception e) {
                return -1L;
         * Wrapper for the command <code>size [fileName]</code>.  If the file does
         * not exist, we return -1;
        public long getFileSize(String fileName)
            throws IOException
            String response = excludeCode(getExecutionResponse("size " + fileName));
            try {
                return Long.parseLong(response);
            } catch (Exception e) {
                return -1L;
         * Wrapper for the command <code>retr [fileName]</code>.
        public boolean downloadFile(String fileName)
            throws IOException
            return readDataToFile("retr " + fileName, fileName);
         * Wrapper for the command <code>retr [serverPath]</code>. The local file
         * path to which we will write is given by <code>localPath</code>.
        public boolean downloadFile(String serverPath, String localPath)
            throws IOException
            return readDataToFile("retr " + serverPath, localPath);
         * Wrapper for the command <code>stor [fileName]</code>.
        public boolean uploadFile(String fileName)
            throws IOException
            return writeDataFromFile("stor " + fileName, fileName);
         * Wrapper for the command <code>stor [localPath]</code>. The server file
         * path to which we will write is given by <code>serverPath</code>.
        public boolean uploadFile(String serverPath, String localPath)
            throws IOException
            return writeDataFromFile("stor " + serverPath, localPath);
         * Set the restart point for the next download or upload operation.  This
         * lets clients resume interrupted uploads or downloads.
        public void setRestartPoint(int point)
            restartPoint = point;
            debugPrint("Restart noted");
         * Gets server reply code from the control port after an ftp command has
         * been executed.  It knows the last line of the response because it begins
         * with a 3 digit number and a space, (a dash instead of a space would be a
         * continuation).
        private int getServerReply()
            throws IOException
            return Integer.parseInt(getFullServerReply().substring(0, 3));
         * Gets server reply string from the control port after an ftp command has
         * been executed.  This consists only of the last line of the response,
         * and only the part after the response code.
        private String getFullServerReply()
            throws IOException
            String reply;
            do {
                reply = inputStream.readLine();
                debugPrint(reply);
            } while(!(Character.isDigit(reply.charAt(0)) &&
                      Character.isDigit(reply.charAt(1)) &&
                      Character.isDigit(reply.charAt(2)) &&
                      reply.charAt(3) == ' '));
            return reply;
         * Added by Julian: Returns the last line of the server reply, but also
         * returns the full multi-line reply in a StringBuffer parameter.
        private String getFullServerReply(StringBuffer fullReply)
             throws IOException
            String reply;
            fullReply.setLength(0);
            do {
                reply = inputStream.readLine();
                debugPrint(reply);
                fullReply.append(reply + lineTerm);
            } while(!(Character.isDigit(reply.charAt(0)) &&
                      Character.isDigit(reply.charAt(1)) &&
                      Character.isDigit(reply.charAt(2)) &&
                      reply.charAt(3) == ' '));
              // remove any trailing line terminators from the fullReply
              if (fullReply.length() > 0) 
                   fullReply.setLength(fullReply.length() - lineTerm.length());
            return reply;
         * Added by Julian: Gets a list of files in the current directory.
         public String listFiles()
              throws IOException
              return listFiles("");
         * Added by Julian: Gets a list of files in either the current
         * directory, or one specified as a parameter. The 'params' parameter
         * can be either a directory name, a file mask, or both (such as
         * '/DirName/*.txt').
         public String listFiles(String params)
              throws IOException
              StringBuffer files = new StringBuffer();
              StringBuffer dirs = new StringBuffer();
              if (!getAndParseDirList(params, files, dirs))
                   debugPrint("Error getting file list");
              return files.toString();
         * Added by Julian: Gets a list of subdirectories in the current directory.
         public String listSubdirectories()
              throws IOException
              return listSubdirectories("");
         * Added by Julian: Gets a list of subdirectories in either the current
         * directory, or one specified as a parameter. The 'params' parameter
         * can be either a directory name, a name mask, or both (such as
         * '/DirName/Sub*').
         public String listSubdirectories(String params)
              throws IOException
              StringBuffer files = new StringBuffer();
              StringBuffer dirs = new StringBuffer();
              if (!getAndParseDirList(params, files, dirs))
                   debugPrint("Error getting dir list");
              return dirs.toString();
         * Added by Julian: Sends and gets the results of a file list command,
         * like LIST or NLST.
        private String processFileListCommand(String command)
            throws IOException
            StringBuffer reply = new StringBuffer();
            String replyString;
            // file listings require you to issue a PORT command,
            // like a file transfer
              boolean success = executeDataCommand(command, reply);
              if (!success)
                   return "";
            replyString = reply.toString();
            // strip the trailing line terminator from the reply
            if (reply.length() > 0)
                 return replyString.substring(0, reply.length() - 1);
            }  else  {
                 return replyString;
          * Added by Julian: Gets a directory list from the server and parses
          * the elements into a list of files and a list of subdirectories.
         private boolean getAndParseDirList(String params, StringBuffer files, StringBuffer dirs)
              throws IOException
              // reset the return variables (we're using StringBuffers instead of
              // Strings because you can't change a String value and pass it back
              // to the calling routine -- changing a String creates a new object)
              files.setLength(0);
              dirs.setLength(0);
              // get the NLST and the LIST -- don't worry if the commands
              // don't work, because we'll just end up sending nothing back
              // if that's the case
              String shortList = processFileListCommand("nlst " + params);
              String longList = processFileListCommand("list " + params);
              // tokenize the lists we got, using a newline as a separator
              StringTokenizer sList = new StringTokenizer(shortList, "\n");
              StringTokenizer lList = new StringTokenizer(longList, "\n");
              // other variables we'll need
              String sString;
              String lString;
              // assume that both lists have the same number of elements
              while ((sList.hasMoreTokens()) && (lList.hasMoreTokens())) {
                   sString = sList.nextToken();
                   lString = lList.nextToken();
                   if (lString.length() > 0)
                        if (lString.startsWith("d"))
                             dirs.append(sString.trim() + lineTerm);
                             debugPrint("Dir: " + sString);
                        }  else if (lString.startsWith("-"))  {
                             files.append(sString.trim() + lineTerm);
                             debugPrint("File: " + sString);
                        }  else  {
                             // actually, symbolic links will start with an "l"
                             // (lowercase L), but we're not going to mess with
                             // those
                             debugPrint("Unknown: " + lString);
              // strip off any trailing line terminators and return the values
              if (files.length() > 0)  {  files.setLength(files.length() - lineTerm.length());  }
              if (dirs.length() > 0)  {  dirs.setLength(dirs.length() - lineTerm.length());  }
              return true;
         * Executes the given FTP command on our current connection, returning the
         * three digit response code from the server.  This method only works for
         * commands that do not require an additional data port.
        public int executeCommand(String command)
            throws IOException
            outputStream.println(command);
            return getServerReply();
         * Executes the given FTP command on our current connection, returning the
         * last line of the server's response.  Useful for commands that return
         * one line of information.
        public String getExecutionResponse(String command)
            throws IOException
            outputStream.println(command);
            return getFullServerReply();
         * Executes the given ftpd command on the server and writes the results
         * returned on the data port to the file with the given name, returning true
         * if the server indicates that the operation was successful.
        public boolean readDataToFile(String command, String fileName)
            throws IOException
            // Open the local file
            RandomAccessFile outfile = new RandomAccessFile(fileName, "rw");
            // Do restart if desired
            if (restartPoint != 0) {
                debugPrint("Seeking to " + restartPoint);
                outfile.seek(restartPoint);
            // Convert the RandomAccessFile to an OutputStream
            FileOutputStream fileStream = new FileOutputStream(outfile.getFD());
            boolean success = executeDataCommand(command, fileStream);
            outfile.close();
            return success;
         * Executes the given ftpd command on the server and writes the contents
         * of the given file to the server on an opened data port, returning true
         * if the server indicates that the operation was successful.
        public boolean writeDataFromFile(String command, String fileName)
            throws IOException
            // Open the local file
            RandomAccessFile infile = new RandomAccessFile(fileName, "r");
            // Do restart if desired
            if (restartPoint != 0) {
                debugPrint("Seeking to " + restartPoint);
                infile.seek(restartPoint);
            // Convert the RandomAccessFile to an InputStream
            FileInputStream fileStream = new FileInputStream(infile.getFD());
            boolean success = executeDataCommand(command, fileStream);
            infile.close();
            return success;
         * Executes the given ftpd command on the server and writes the results
         * returned on the data port to the given OutputStream, returning true
         * if the server indicates that the operation was successful.
        public boolean executeDataCommand(String command, OutputStream out)
            throws IOException
            // Open a data socket on this computer
            ServerSocket serverSocket = new ServerSocket(0);
            if (!setupDataPort(command, serverSocket)) return false;
            Socket clientSocket = serverSocket.accept();
            // Transfer the data
            InputStream in = clientSocket.getInputStream();
            transferData(in, out);
            // Clean up the data structures
            in.close();
            clientSocket.close();
            serverSocket.close();
            return isPositiveCompleteResponse(getServerReply());   
         * Executes the given ftpd command on the server and writes the contents
         * of the given InputStream to the server on an opened data port, returning
         * true if the server indicates that the operation was successful.
        public boolean executeDataCommand(String command, InputStream in)
            throws IOException
            // Open a data socket on this computer
            ServerSocket serverSocket = new ServerSocket(0);
            if (!setupDataPort(command, serverSocket)) return false;
            Socket clientSocket = serverSocket.accept();
            // Transfer the data
            OutputStream out = clientSocket.getOutputStream();
            transferData(in, out);
            // Clean up the data structures
            out.close();
            clientSocket.close();
            serverSocket.close();
            return isPositiveCompleteResponse(getServerReply());   
         * Added by Julian: Executes the given ftpd command on the server
         * and writes the results returned on the data port to the given
         * StringBuffer, returning true if the server indicates that the
         * operation was successful.
        public boolean executeDataCommand(String command, StringBuffer sb)
            throws IOException
            // Open a data socket on this computer
            ServerSocket serverSocket = new ServerSocket(0);
            if (!setupDataPort(command, serverSocket)) return false;
            Socket clientSocket = serverSocket.accept();
            // Transfer the data
            InputStream in = clientSocket.getInputStream();
            transferData(in, sb);
            // Clean up the data structures
            in.close();
            clientSocket.close();
            serverSocket.close();
            return isPositiveCompleteResponse(getServerReply());   
         * Transfers the data from the given input stream to the given output
         * stream until we reach the end of the stream.
        private void transferData(InputStream in, OutputStream out)
            throws IOException
            byte b[] = new byte[BLOCK_SIZE];
            int amount;
            // Read the data into the file
            while ((amount = in.read(b)) > 0) {
                out.write(b, 0, amount);
         * Added by Julian: Transfers the data from the given input stream
         * to the given StringBuffer until we reach the end of the stream.
        private void transferData(InputStream in, StringBuffer sb)
            throws IOException
            byte b[] = new byte[BLOCK_SIZE];
            int amount;
            // Read the data into the StringBuffer
            while ((amount = in.read(b)) > 0) {
                sb.append(new String(b, 0, amount));
         * Executes the given ftpd command on the server and writes the results
         * returned on the data port to the given FilterOutputStream, returning true
         * if the server indicates that the operation was successful.
        private boolean setupDataPort(String command, ServerSocket serverSocket)
            throws IOException
            // Send our local data port to the server
            if (!openPort(serverSocket)) return false;
            // Set binary type transfer
            outputStream.println("type i");
            if (!isPositiveCompleteResponse(getServerReply())) {
                debugPrint("Could not set transfer type");
                return false;
            // If we have a restart point, send that information
            if (restartPoint != 0) {
                outputStream.println("rest " + restartPoint);
                restartPoint = 0;
                // TODO: Interpret server response here
                getServerReply();
            // Send the command
            outputStream.println(command);
            return isPositivePreliminaryResponse(getServerReply());
         * Get IP address and port number from serverSocket and send them via the
         * <code>port</code> command to the ftp server, returning true if we get a
         * valid response from the server, returning true if the server indicates
         * that the operation was successful.
        private boolean openPort(ServerSocket serverSocket)
            throws IOException
            int localport = serverSocket.getLocalPort();
            // get local ip address
            InetAddress inetaddress = serverSocket.getInetAddress();
            InetAddress localip;
            try {
                localip = inetaddress.getLocalHost();
            } catch(UnknownHostException e) {
                debugPrint("Can't get local host");
                return false;
            // get ip address in high byte order
            byte[] addrbytes = localip.getAddress();
            // tell server what port we are listening on
            short addrshorts[] = new short[4];
            // problem:  bytes greater than 127 are printed as negative numbers
            for(int i = 0; i <= 3; i++) {
                addrshorts[i] = addrbytes;
    if (addrshorts[i] < 0)
    addrshorts[i] += 256;
    outputStream.println("port " + addrshorts[0] + "," + addrshorts[1] +
    "," + addrshorts[2] + "," + addrshorts[3] + "," +
    ((localport & 0xff00) >> 8) + "," +
    (localport & 0x00ff));
    return isPositiveCompleteResponse(getServerReply());
    * True if the given response code is in the 100-199 range.
    private boolean isPositivePreliminaryResponse(int response)
    return (response >= 100 && response < 200);
    * True if the given response code is in the 300-399 range.
    private boolean isPositiveIntermediateResponse(int response)
    return (response >= 300 && response < 400);
    * True if the given response code is in the 200-299 range.
    private boolean isPositiveCompleteResponse(int response)
    return (response >= 200 && response < 300);
    * True if the given response code is in the 400-499 range.
    private boolean isTransientNegativeResponse(int response)
    return (response >= 400 && response < 500);
    * True if the given response code is in the 500-5

    ok i tried explaining th eproblem in the previous post, but i apologize if my explanation was poor. anyways, i tried to look into it further by doing a printStackTrace() and believe it may be a read error. here is my new updated snippet, and also a link to a screenshot ([click here for screenshot|http://img143.imageshack.us/my.php?image=picture4qr0.png]) of what the error looks like on my end. it seems like a socket is not being read, or maybe it is initialized properly. Again I apologize if my problem is vague, but I do appreciate your input. thanks.
    updated code snippet
    public void uploadFiles()
              statusLabel.setVisible(true);
              errorLabel.setVisible(true);
              uploadButton.setVisible(false);
              footer.setVisible(false);
              holdingPanel.setVisible(false);
              pbar.setVisible(true);
              pbar = new JProgressBar();
              pbar.setMinimum(0);
              float Total=0;
              for (int i=0; i<fileLengths.size(); i++)
                   if(((java.lang.Boolean)model.getValueAt(i,1)).toString().equals("true"))
                        Total+=Float.parseFloat((String)fileLengths.get(i));
              pbar.setMaximum((int)Total);
              String info="";
              try
                   ftp=new FTPConnection(false);
                   ftp.connect("ftp.chris-malcolm.com");
                   if (ftp.login("chrismal", "***"))
                        statusLabel.setText("Status: Connected.");
                        info+="Successfully logged in!\n";
                        info+="System type is: " + ftp.getSystemType()+"\n";
                        info+="Current directory is: " + ftp.getCurrentDirectory()+"\n";
                        if (ftp.changeDirectory("/www/images/"))
                             info+="directory changed to: " + ftp.getCurrentDirectory()+"\n";
                                                 try
                             for (int i=0; i<allFiles.size(); i++)
                                  if(((java.lang.Boolean)model.getValueAt(i,1)).toString().equals("true"))
                                       String f=client.verifyFileName((String)model.getValueAt(i,0));
                                       String f2=""+((File)allFiles.get(i)).getPath();
                                       info+="filename: "+f2+"\n";
                                       if (ftp.uploadFile(f2))
                                            statusLabel.setText("Status: Uploading "+f+" - "+i+" of "+calculateTotalFiles()+" files(s)");
                                            pbar.setValue(Integer.parseInt((String)fileLengths.get(i)));
                                       else
                                            errorLabel.setText("Error occured while uploading"+f2+"\n");
                        catch(Exception de) 
                             StringWriter sw = new StringWriter();
                                  PrintWriter pw = new PrintWriter(sw);
                                  de.printStackTrace(pw);
                                  pw.close();
                                  //errorLabel.setText("<html>ERROR:"+sw.toString().replace("\n", "<br>")+"</html>");
                                  info+="Error: "+de.getMessage()+"\n";
                                  info+="Trace: "+sw+"\n";
                             try { ftp.disconnect(); statusLabel.setText("Status: disconnected.");}  catch(Exception e2)  {};
                        else
                             info+="could not change directory\n";
                   else
                        info+="could not login";
              catch (Exception e)
                   StringWriter sw = new StringWriter();
                                  PrintWriter pw = new PrintWriter(sw);
                                  e.printStackTrace(pw);
                                  pw.close();
                                  info+="Error: "+e.getMessage()+"\n";
                                  info+="Trace: "+sw+"\n";
                   try { ftp.disconnect();  statusLabel.setText("Status: disconnected.");}  catch(Exception e2)  {};
              errorLabel.setText("ERROR:"+info);
              JOptionPane.showMessageDialog(this, info, "test", JOptionPane.PLAIN_MESSAGE);
              try { ftp.disconnect(); statusLabel.setText("Status: disconnected.");}  catch(Exception e2)  {};
         Edited by: cjm771 on Jul 13, 2008 7:23 PM

  • Uploading problems File I/O Error 2038

    Is there any way to get additional information about why this
    error occurs? I am trying to upload a file, but I keep getting a
    File I/O error. When I run the app on my local machine the file
    upload succeeds, the I get a File I/O error. When I try to run the
    same app up on my server I get the same error, but the upload
    script is never even called (i.e. the HTTP request is never sent).
    Any ideas? How can I figure out why I am getting this error?
    Thanks,
    Derek

    Hi
    Can you elaborate on what you did when you changed the
    security settings -> This was fixed by changing the security
    settings.
    I think too that my problem has something to do with security
    settings but I do not know for sure. I only know that my server
    side script is never reached when trying to upload from a MAC
    platform. I'm using a webhotel so I'm pretty limited in changing
    the settings.
    Any help will be greatly appreciated.
    Have a look at my case:
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=585&threadid=1311564

  • File Upload problem: JSF, IBM WPS and Portlet - Please HELP Vey Very Urgent

    I want to upload a file from the front end using JSF and Portlets deployed on IBM WebSphere Portal.
    I have used Apache's commons file upload functionality as the file upload provided in JSF doesnot work with portlets and the action event is not invoked If I keep enctype="multipart/form-data". So I included 3 forms in my Faces JSP file.
    1) h:form = For displyign error message on screen
    2) html:form = Include the enctype="multipart/form-data" and the input type file for uploading. And a submit button
    3) h:form: Here I have a command link which is remotely excuted on click of sumit button in my html form. This is to invoke the action event in the pagecode to get the bean value from the context.
    Now in the my doView method in the portlet, isMultipartContent(httpservletrequest) always returns null as the content type is text/html and not multipart. Onclick of the submit button in the the html form I am calling a javascript function which sets the __LINK_TARGET__ to the command link in the 3rd h:form which will call the page code.
    The problem here is action is invoked only when I return false from the above javascript else it will trigger for the first time and from second time onwards it will not invoke the action event in the pagecode method. Whent the javascript function returns false, the content type is always text/html. However if I return "true" from the javascript the content type is multipart/form-data, but the action is not triggered for the second time. So basically when the javascript functions returns true, for the first click everything works perfectly. When it returns false, the content type is text/html, but the action is invoked in the page code every time.
    Returning always true would solve my problem with the content type, but the action with the command link will not get invoked always as its some type of problem with h:commanLink :(.
    I guess I gave too much info. Heres my code stepby step.
    Can somebody please tell me , how I should also invoke the action in the page code and get the content type as "multipart/form-data" at the same time.
    1:
    ======================= Faces JSP File: BPSMacro.jsp ====================
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <meta name="GENERATOR" content="IBM Software Development Platform">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <%@taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
    <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%>
    <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@taglib uri="http://www.ibm.com/jsf/html_extended" prefix="hx"%>
    <%@taglib uri="/WEB-INF/tld/j4j.tld" prefix="j4j"%>
    <%@taglib uri="/WEB-INF/tld/core.tld" prefix="core"%>
    <%@page language="java" contentType="text/html; charset=ISO-8859-1"
         pageEncoding="ISO-8859-1" session="false"%>
    <portlet:defineObjects />
    <link rel="stylesheet" type="text/css"
         href='<%= renderResponse.encodeURL(renderRequest.getContextPath() + "/theme/stylesheet.css") %>'
         title="Style">
    <script type="text/javascript">
    function formSubmit() {
         var formName2 = document.getElementById("proxy_form_main_").title;
         var formName1 = document.getElementById("BPSMacroFormId").title;
         document.getElementById("__LINK_TARGET__").value = document.getElementById("proxy_HD_COMMAND_").title;
         document.getElementById(formName2).submit();
         return false;
    </script>
    <f:view>
         <hx:scriptCollector id="bpsMacroScriptCollector">
              <f:loadBundle var="bps" basename="bordereauprocessingsystem" />
              <table bgcolor="#FFF9C3">
                   <tr>
                        <td><h:form id="BPSMacroFormMain" styleClass="form">
                             <table class="tablemiddle" cellspacing="0" cellpadding="0">
                                  <tr>
                                       <td><h:messages layout="table" styleClass="errormessage"
                                                 id="ValidationErrorMsg" /> </td>
                                  </tr>
                             </table>
                             <j4j:idProxy id="proxy_form_main_0_" />
                        </h:form></td>
                   </tr>
                   <tr>
                        <td>
                        <form id="BPSMacroFormId" enctype="multipart/form-data">
                        <table bgcolor="#FFF9C3">
                             <tr>
                                  <td height="36" width="324">Worksheet <input type="file"
                                       name="upfile" /></td>
                             </tr>
                                  <tr>
                                       <td align="center" width="324"><input TYPE="submit"
                                       onclick="return formSubmit();" value="Upload">
                                  </td>
                             </tr>
                        </table>
                        </form>
                        </td>
                   </tr>
                   <tr>
                        <td>
                        <h:form id="BPSMacroFormMain2" styleClass="form">
                             <table cellspacing="2" cellpadding="2" class="tablemiddle">
                                  <tbody>
                                       <tr>
                                            <td colspan="2" align="center"><h:commandLink
                                                 styleClass="commandLink" id="lnkuserdelete"
                                                 action="#{pc_BPSMacro.doIdUpload1Action}">
                                                 <hx:graphicImageEx
                                                      styleClass="graphicImageEx" id="imgBtnCreateUser"
                                                      value="/theme/images/btnUpload.gif" style="border:0;cursor:pointer"></hx:graphicImageEx>
                                                 <j4j:idProxy id="proxy_HD_COMMAND_" />
                                            </h:commandLink></td>
                                            <h:inputHidden id="dtSize"
                                                 value="#{pc_BPSMacro.fileDetailsList.clicked}">
                                                 <j4j:idProxy id="proxy_clicked_" />
                                            </h:inputHidden>
                                       </tr>
                                  </tbody>
                             </table>
                             <j4j:idProxy id="proxy_form_main_" />
                        </h:form>
                   </td>
                   </tr>
              </table>
         </hx:scriptCollector>
    </f:view>
    ================== END: FACES JSP FILE: BPSMacro.jsp ========================
    2:
    =================== Action event in the Page Code: BPSMacro.java ============
    public String doIdUpload1Action() {
              System.out.println("PageCode");
              FacesContext context = FacesContext.getCurrentInstance();
              BPSMacroDetailsDataBean fileDetails = (BPSMacroDetailsDataBean)context.getApplication().createValueBinding("#{fileDetails}").getValue(context);
              BPSMacroListDataBean fileDetailsList = (BPSMacroListDataBean)context.getApplication().createValueBinding("#{fileDetailsList}").getValue(context);
              PortletSession sess = (PortletSession)context.getExternalContext().getSession(false);
              sess.setAttribute("BPS_MACRO_CONTEXT", context, PortletSession.APPLICATION_SCOPE);
              sess.setAttribute("BPS_MACRO_FILE_DETAILS", fileDetails, PortletSession.APPLICATION_SCOPE);
              sess.setAttribute("BPS_MACRO_FILE_LIST", fileDetailsList, PortletSession.APPLICATION_SCOPE);
              HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();
              boolean isMultipart = ServletFileUpload.isMultipartContent(request);
              request.getContentType();
              return "gotoBPSMacro";
    ============== END Of Page Code Action event ==============================
    3:
    ============== doView() Portlet method ================================
    public void doView(RenderRequest arg0, RenderResponse arg1)
         throws PortletException, IOException {
              String METHOD_NAME = "doView(RenderRequest arg0, RenderResponse arg1)";
              Logger.debug(this.getClass(), METHOD_NAME, "Entering BPSMacroPortlet");
              FacesContext context = FacesContext.getCurrentInstance();      
              PortletSession sess1 = arg0.getPortletSession(true);
              BPSMacroDetailsDataBean fileDetails = new BPSMacroDetailsDataBean();
              BPSMacroListDataBean fileDetailsList = new BPSMacroListDataBean();
              context = (FacesContext)sess1.getAttribute("BPS_MACRO_CONTEXT", PortletSession.APPLICATION_SCOPE);
              if(context != null){
                   fileDetails = (BPSMacroDetailsDataBean)sess1.getAttribute("BPS_MACRO_FILE_DETAILS", PortletSession.APPLICATION_SCOPE);
                   fileDetailsList = (BPSMacroListDataBean)sess1.getAttribute("BPS_MACRO_FILE_LIST", PortletSession.APPLICATION_SCOPE);
              sess1.removeAttribute("BPS_MACRO_CONTEXT", PortletSession.APPLICATION_SCOPE);
              sess1.removeAttribute("BPS_MACRO_FILE_DETAILS", PortletSession.APPLICATION_SCOPE);
              sess1.removeAttribute("BPS_MACRO_FILE_LIST", PortletSession.APPLICATION_SCOPE);
              HttpServletRequest servletRequest = (HttpServletRequest)arg0;
              PortletRequest pReq = (PortletRequest)arg0;
              HttpServletResponse servletResponse= (HttpServletResponse)arg1;
              System.out.println("\n\n Content Type" + servletRequest.getContentType());
              try{
                   if(context != null){
              boolean isFileMultipart = ServletFileUpload.isMultipartContent(servletRequest);
              System.out.println("\nFILE TO BE UPLOADED IS MULTIPART ? " + isFileMultipart);
              if(isFileMultipart){
                   FileItemFactory factory = new DiskFileItemFactory();
                   ServletFileUpload upload = new ServletFileUpload(factory);
                   List items = upload.parseRequest(servletRequest);
                   Iterator iterator = items.iterator();
                   while (iterator.hasNext()) {
                        FileItem item = (FileItem) iterator.next();
                        InputStream iStream = item.getInputStream();
                        ByteArrayOutputStream ByteArrayOS = new ByteArrayOutputStream();
                        int sizeofFile =(int) item.getSize();
                        byte buffer[] = new byte[sizeofFile];
                        int bytesRead = 0;
                        while( (bytesRead = iStream.read(buffer, 0, sizeofFile)) != -1 )
                             ByteArrayOS.write( buffer, 0, bytesRead );
                        String data = new String( ByteArrayOS.toByteArray() );
                        int k = 0;
                        //Check if the file is Refund or Premium
                        int dynamicArraySize = 0;// = st2.countTokens() * 9;
                        dynamicArraySize = st2.countTokens() * 9;
                        if (!item.isFormField() ){
                             File cfile=new File(item.getName());
                             String fileName = "";
                             String separator = "\\";
                             int pos = item.getName().lastIndexOf(separator);
                             int pos2 = item.getName().lastIndexOf(".");
                             if(pos2>-1){
                                  fileName =item.getName().substring(pos+1, pos2);
                             }else{
                                  fileName =item.getName().substring(pos+1);
                             File fileToBeUploaded=new File("C:\\Sal\\BPS MACRO\\FileTransfer\\Desti", fileName);
                             item.write(fileToBeUploaded);
                             validate.displaySuccessMessage(context);
              }catch(Exception e){System.out.println(e);
              Logger.debug(this.getClass(), METHOD_NAME, "Leaving BPSMacroPortlet");
              super.doView(arg0, arg1);
    ==== END: doView method in the portle class. ================================
    Thanks.

    one more question. Is there a way where I can submit two forms ?
    Thats is submit 2nd form only when the first form is submitted.
    I tried this it works.
    function formSubmit(){
    document.form1.submit();
    alert();
    document.form2.submit();
    But If I dont put an alert(basically it disables the parent page) in between, only the second form is submitted.
    If I put a delay of say 3 seconds in between then it will throw a SOCKET CLOSED error in the code triggered due to first form submit.
    Thus disabling the paresnt page for a few seconds is reolving my problem.
    Any ideas ?
    Well Basically when the Alert pop's up the parent page "STALLS" and thus the form2 does not submit till I click on OK, Is there a way I can stall the browser/Parent JSP page using JAVA SCRIPT ??
    Edited by: hector on Oct 9, 2007 11:09 AM
    Edited by: hector on Oct 9, 2007 2:12 PM

  • Lightbox gallery extension - upload problems!

    Hi,
    I've made a small test site in Dreamweaver CS5 with a photo gallery in a Lightbox extension ( that I've added from Dreamweaver extensions ). Everything looks and works the way I want it to in Dreamweaver Safari preview...but as soon as I upload my test site, the Lightbox Gallery doesn't work anymore. I asked my webhotel support for help, but they say that I should contact the developer for an answer ???
    I'm thinking that it must a very common problem, does anyone have a clue what the problem could be?
    ( My webhotel is an  advanced LINUX server ...as if I knew what that means ;-)
    Thanks and Merry Christmas !

    You have:
    <a href="nyhavn.jpg" title="Nyhavn, heritage harbour and a popular
    place to go for dinner or a drink.">
    <img src="nyhavn_s.jpg" width="72" height="73" alt="" /> </a>
    Are you not supposed to have   rel="lightbox" added to it? Such as
    <a href="nyhavn.jpg" title="Nyhavn, heritage harbour and a popular
    place to go for dinner or a drink.">
    <img src="nyhavn_s.jpg" rel="lightbox" width="72" height="73" alt="" /> </a>
    On closer inspection, if you look at your  "scripts/lightbox.js"
    It is not a js file at all, it is an html file....what happened to your original js file?
    Gary

Maybe you are looking for

  • Photoshop CS2 won't let me open?

    I received Photoshop CS2 from Adobe because they shut down the CS server, killing my program. I installed the program using their serial number and when I open it, it says the serial number was not installed and then when I push 'ok' it shuts down. H

  • Date format for Calendar Prompt  in Oracle BI

    Hi, 1) In Oracle Answers, I need to have this format : dd-MMM-yy in a Calendar Prompt I've changed in localedefinitions.xml : <property name="dateShortFormat">dd-MMM-yy</property> <property name="dateOrder">dmy</property> <property name="dateSeparato

  • Mail service stuck starting in Mavericks

    After installing Mavericks server I've got a problem with the mailserver. In the Server.app it keeps showing as starting, but it never starts. the terminal command 'serveradmin fullstatus mail' shows that everything is started as it should, except th

  • Batch Management Procedure

    hi all, can any body explain me how to configure batch management in MM? Is there any types in Batches. i need full settings to do in MM. i will be great full to all in advance.

  • ActiveX Crystal Report Control

    Post Author: JLTerMarsch CA Forum: General I am using Crystal Reports 8.5 Developer. I know it is old, but I am using the original Crystal Reports Control ActiveX. Where can I get a list of the available commands available to me? e.g. printreport, ex