Upload file without user intervention

I know that there's been some topics like this before but I have more trouble.
My goal is this: I file should be automaticly uploaded to my servlet and the I want the internet browser to handle the response.
Because of the restrictions that lies, I think I need to create a small client program that simulates a post request to my servlet and then somehow make IE handle the response.
I've gotten some source code for the simulation of the post request from previous posts in this forum (see below). I haven't really got it to work but that shouldn't be a big problem. The problem is, how do I get IE to handle the response?
Here's the source code for the java program that simulates the post request:
import java.util.*;
import java.io.*;
import java.net.*;
class FileUpload
  // true globals
  // Anything that's unique will work
  static final String CONTENT_BOUNDARY =
"-----------------------------7d22a63810058e";
  public FileUpload() {
  public static void main (String [] args) {
    // whatever file you care to upload
     String uploadFileName = "/testFile.txt";
     FileInputStream fis1 = null;
     OutputStream os1 = null;
     InputStream is1 = null;
     try
          File file1 = new File(uploadFileName);
          fis1 = new FileInputStream(file1);
          // the URL of your upload application
          URL testPost = new URL("http://localhost:8080/test/ReadFile");
          URLConnection huc1 = testPost.openConnection();
          huc1.setAllowUserInteraction(true);
          huc1.setDoOutput(true); // turns it into a post
          huc1.setRequestProperty("Content-Type", "multipart/form-data;boundary="+CONTENT_BOUNDARY);
          huc1.setRequestProperty("User-Agent", "Mozilla/4.7 [en] (WinNT; U)");
          huc1.setRequestProperty("Accept-Language", "en-us");
          huc1.setRequestProperty("Accept-Encoding", "gzip, deflate");
          huc1.setRequestProperty("Accept",
               "image/gif, image/x-xbitmap,image/jpeg, image/pjpeg, "+
               "application/vnd.ms-excel, application/msword, "+
               "application/vnd.ms-powerpoint, application/pdf, application/x-comet, */*");
          huc1.setRequestProperty("CACHE-CONTROL", "no-cache");
          os1 = huc1.getOutputStream();
          // Field 1 a Field of data
          os1.write(
               (CONTENT_BOUNDARY +
               "\r\n"+
               "Content-Disposition: form-data; name=\"txtTitle\"\r\n\r\nTest"+
               "Segment\r\n"
               ).getBytes());
          // Field 2 - the file, name is "uploadFile"
          os1.write(
               (CONTENT_BOUNDARY + "\r\n" +
               "Content-Disposition: form-data; name=\"source\"; filename=\"" +
               uploadFileName +
               "\"\r\nContent-Type: audio/x-pn-realaudio\r\n\r\n"
               ).getBytes());
          byte [] fileStuff = new byte[512];
          int howMany = -1;
          int totMany = 0;
          howMany = fis1.read(fileStuff, 0, 512);
          while (howMany != -1)
               totMany += howMany;
               os1.write(fileStuff, 0, howMany);
               howMany = fis1.read(fileStuff, 0, 512);
          System.err.println("read " + totMany + " bytes from file, wrote to outputstream.");
          fis1.close();
          fis1 = null;
          os1.write(("\r\n" + CONTENT_BOUNDARY + "--\r\n").getBytes());
          is1 = huc1.getInputStream();
          byte [] urlStuff = new byte[512];
          howMany = is1.read(urlStuff, 0, 512);
          while (howMany != -1)
               System.out.write(urlStuff, 0, howMany);
               howMany = is1.read(urlStuff, 0, 512);
          System.err.println("that was your output.");
          is1.close();
          is1 = null;
          os1.close();
          os1 = null;
     catch (Exception ex)
          System.err.println("Exception: " + ex);
          ex.printStackTrace();
         finally
          if (fis1 != null)
               try
                    fis1.close();
               catch(Exception ok_to_eat)
                 // ok to ignore this
          if (is1 != null)
          try
               is1.close();
          catch(Exception ok_to_eat)
            // ok to ignore this
          if (os1 != null)
               try
                      os1.close();
               catch (Exception ok_to_eat)
            // ok to ignore this
}Any suggestions are highly appreciated.
Thanks / Daniel

The problem is, how do I get IE to handle the response?You can't. The response has to be handled by whatever sent the request.

Similar Messages

  • [CS4]  save on a local file without  user intervention

    hey,...sorry for my english...
    i work with a other application who need to have the
    information written in the local file without an user intervention
    so...
    i would like to know if it s possible to write or rewrite on
    a local file without intervention of the user...
    whitout the ""save dialogue box" or with a managed save
    dialogue box...
    how to write in a local file without user intervention...
    i need really an answer to make real my project...
    thans for your conprehension

    hey
    thx a lot for your help ...
    if i understand well ...
    it is possible to write or rewrite in a specific folder
    who is determinated by the application folder of
    an specific AIR apllication
    who during his install give the ""authorization to
    write/rewrite /save in his specific installation foder"
    so it s possible with combination of an AIR application.....
    can you give me some information about this AIR application
    that i must build...
    some direction to ask help
    because i dont have the knowledges to do that
    what style/type of AIR application
    what charachteristics of this AIR application....
    so some information that can i use to ask help in the good
    place...
    one more time thx a lot for your help...;)

  • Upload file without user action.

    Hi,
    Here is my requirement: I need to upload file ( text / excel file ) from local PC without user interaction.
    I try using file_upload element and I set visible property as none ( so user doesn't see this element ) but I don't know how to get the file data. I only can set the file_name and mime_type property.
    Please help me how to get this file data. Or how to upload file from local PC without file_upload element.
    Regards,

    Hi Jatra.
    I guess there are several function modules you can use. Try this : UPLOAD_FILES.
    Maybe you can solve your issue with it. Otherwise search the Abap Forum on how to upload files from PC to WAS.
    Cheers,
    Sascha

  • Can You Play Multiple Playlists Without User Intervention

    Can you stack and play multiple playlists? ie if you had three playlists of 50 songs each, could you pick all three, play all the songs in the first playlist, when it is finished move automatically to the second playlist play its songs then automatically move to the third without user intervention? And if so, can you play each of these in shuffle mode?

    There's no "impromptu" method of doing so that I know of.
    As far as un-impromptu methods (it's always fun inventing words), it will depend on whether you want to listen to this mega-playlist on an iPod or just with iTunes.
    If it's just with iTunes, you can go to the File menu > New Folder command and create a new folder which we can call the Mega-Playlist folder. Drag the three playlists in question into that folder. When you select that folder and press Play, iTunes should go through all the songs.
    If it's on an iPod, since Folders don't transfer over from iTunes, the only solution I know of would be to create a Smart Playlist with iTunes that will -
    Match any of the following rules:
    Playlist is the first playlist +
    Playlist is the second playlist +
    Playlist is the third playlist.
    Synching this mega-playlist to your iPod will allow you to select it from the Playlist menu.
    Shuffle mode would shuffle songs from all three playlists together, not shuffle songs from the first playlist before moving on to shuffling songs from the second playlist before shuffling songs from the third playlist.

  • Creating a jar file without user compliation

    Hi, i got a problem here and i do not know how to go about doing it, any help will be much appreciated...
    I need a JAR file in my integration bin shell
    this bin shell will read my JAR file
    The user will create the MAIN class file with something call a template engine specifying some stuff that can be changed
    after which together with some existing .java class files, one .XML file(which the user specify with template engine) my program is to compile them automatically without user intervention and produce the JAR file.
    any suggestions? thannks

    Hmm, this sounds to me like a task for build tool like ANT.
    If you absolutely need to do this yourself look at java.util.jar and into the programmatic interface of javac (get the JDK source code distribution for this).

  • Generate a Report Dynamically without User Intervention and Output to XML

    Here's the scenario for which I am trying to find a solution. Any help would be greatly appreciated.
    I have a series of reports that the users generate from a UI by selecting the report, setting the values for a list of parameters, and then click a submit button. The report is generated in the UI for them to view. They can print it from here or export it to Excel.
    They would like to be able to schedule a report to run daily without user intervention using a saved set of parameters. The system would run the report automatically and email it to a defined set of email addresses.
    To do this, we need to have the report generated in a string or xml so a Java process can read it and email it.
    I see that I can change a report's template to export:xml so I feel that it is possible. How can I export a report to XML without user intervention? Can the report template be changd dynamically at runtime? Ideally, I need some way to call this same report and have it output as a string data or xml to be used by a Java process that would store and generate the report for email.

    Hi Kumar,
    From Program1 you are calling Program2, using submit syntax (inside Program1).
    While using submit, if you have correctly filled up the selection screen of program2, then it will AUTOMATICALLY get executed, WITHOUT F8.
    If there is any compulsary field in program 2, which does not get populated, then it will not run automatically, or unless some special code is written in program2.
    If you do not want the output of Program2 on screen, then u can use
    SUBMIT Program2 AND RETURN.
    In that case, no selection screen (of program2) will appear and neither the output of program 2.
    Regards,
    Amit Mittal.
    Edited by: Amit Mittal on Dec 23, 2009 4:10 PM

  • Material creation without user intervention

    i have to create a material without user intervention. i am using BAPI_MATERIAL_SAVEDATA for this. it is not showing any error. but the return is having the message 'No description found'. how to transfer the description to this bapi.
    this is the code i am trying:
    DATA:  mnum like zmara01-mno,
           mat_data like BAPIMATHEAD,
           plantx_data like BAPI_MARCX,
           salesx_data like BAPI_MVKEX,
           sale_data like bapi_mvke,
           plant_data like bapi_marc,
           mate_data like bapi_makt,
           E1BP_MAKT like E1BP_MAKT,
           cli_data like bapi_mara.
    DATA: E_RETURN LIKE BAPIRET2.
    data: MATERIALDESCRIPTION like BAPI_MAKT
                      occurs 0 with header line.
    *data: m(18) type c.
    CALL FUNCTION 'NUMBER_GET_NEXT'
            EXPORTING
              NR_RANGE_NR                  = '01'
              OBJECT                       = 'ZMNUMBER'
             QUANTITY                      = '1'
           IMPORTING
             NUMBER                        = mnum.
    message i003(zmsg) with mnum.
    mat_data-material = mnum.
    mat_data-ind_sector = 'I'.
    mat_data-matl_type = 'DIEN'.
    mat_data-basic_view = 'X'.
    cli_data-base_uom = 'EA'.
    cli_data-base_uom_iso = 'X'.
    sale_data-sales_org = 'EISO'.
    sale_data-distr_chan = 'SR'.
    salesx_data-sales_org = 'EISO'.
    salesx_data-distr_chan = 'SR'.
    plant_data-plant = 'EIHO'.
    plantx_data-plant = 'EIHO'.
    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
      EXPORTING
        HEADDATA                   = mat_data
       CLIENTDATA                 = cli_data
      CLIENTDATAX                =
       PLANTDATA                  = plant_data
       PLANTDATAX                 = plantx_data
      FORECASTPARAMETERS         =
      FORECASTPARAMETERSX        =
      PLANNINGDATA               =
      PLANNINGDATAX              =
      STORAGELOCATIONDATA        =
      STORAGELOCATIONDATAX       =
      VALUATIONDATA              =
      VALUATIONDATAX             =
      WAREHOUSENUMBERDATA        =
      WAREHOUSENUMBERDATAX       =
       SALESDATA                  = sale_data
       SALESDATAX                 = salesx_data
      STORAGETYPEDATA            =
      STORAGETYPEDATAX           =
      FLAG_ONLINE                = ' '
      FLAG_CAD_CALL              = ' '
      NO_DEQUEUE                 = ' '
    IMPORTING
       RETURN                     = E_RETURN
    TABLES
       MATERIALDESCRIPTION        =  MATERIALDESCRIPTION
      UNITSOFMEASURE             =
      UNITSOFMEASUREX            =
      INTERNATIONALARTNOS        =
      MATERIALLONGTEXT           =
      TAXCLASSIFICATIONS         =
      RETURNMESSAGES             =
      PRTDATA                    =
      PRTDATAX                   =
      EXTENSIONIN                =
      EXTENSIONINX               =
    loop at materialdescription.
    message I004(I) with materialdescription-matl_desc.
    endloop .
    MESSAGE I004(I) WITH E_RETURN-TYPE.
        if sy-subrc = 0.
         message i005(zmsg).
        elseif sy-subrc <> 0.
         message e006(zmsg).
        endif.
    i am trying to give direct entries to test it . please help in this issue immediately.

    Hi dear,
    welcome on board!
    If you want an answer immediately I think you have to post your question in a more appropriate forum...
    take a look to https://www.sdn.sap.com/sdn/collaboration.sdn and choose one of the available forums !
    Good luck!
    Roberto

  • Animate elements one by one without user intervention

    Hi, Good Day,
    I have series of rectangles and textblocks on page.
    I need to show them moving at different places one by one according to the contents of textblock without user intervention.
    If I use for loop then it show movement of only last rectangle as I have to stop the storyboard in each iteration of loop.
    Is there any way to move these rectangles automatically one after another????
    sunaina

    A storyboard has a completed event.  I think that's the easiest way to handle this sort of requirement.
    You could chain them.
    So you get a reference to a storyboard, add a handler to it's completed event which starts the next storyboard...
    And start it.
    Obviously you will have storyboards which do something or other but here's how I attach anonymous completed eventhandlers to a storyboard:
    Storyboard sb1 = new Storyboard();
    Storyboard sb = new Storyboard();
    sb.Duration = new TimeSpan(0, 0, 1);
    sb.Completed += new EventHandler(delegate(object s, EventArgs a)
    sb1.Begin();
    sb.Begin();
    Hope that helps.
    Recent Technet articles:
    Property List Editing;  
    Dynamic XAML

  • Upload file without asking user for the file

    Hi,
    I need to upload a file to server, but from my code, not using the file upload from page.
    I have created a xml file and I need to upload to server when user open a web browser (without asking user to select a file).
    How do I proceed??, or what kind of libraries do I must use?
    thanks

    davisote wrote:
    Hi,
    thanks for answer.
    Let me try to explain again (I think its very simple).Simple, yes. But not very thorough.
    I have developed a web application using JSF.So all the code is running on the server, right? There are no Applets, Applications or WebStart applications involved. Right?
    My application has a splash screen where I show data. I have developed a bean to connect to my database (sql server), extract this data and create an xml (using DOM) file like:
    <news>
    <simplenews id="1"> Value </simplenews>
    </news>And that bean runs ... where? Server again?
    (important step) Once I have created the xml file in my bean I want to upload to the server to a place like /WEB-INF/news.
    If the code is running on the server, then "uploading" is the wrong term, as there's nowhere to upload to, since you're already on the server.
    This may sound like nit-picking, but you're sending us on a wrong trail with this phrase.
    Once the file is on the server with another bean I read the xml fileWhy don't you simply store it in the application scope and let everyone access it from there? It doesn't sound as if the XML is huge.
    As you can see I haven't a web page where to show an upload file componetYou also don't want to "upload" anything from the client, from the sound of it.
    You simply want to transfer data between to server-side components, if I understood you correctly.

  • HOw to download a file in background without user intervention?

    Hello people,
    A few hours ago I asked a couple of guys how to download a file to html. For that I am most thankful, and as mentioned this is a two part question, my other question is about how to proccess downloading the html in background and to automatically send it to a folder or other path. Without any user intervention.
    Example, I run a long report to be downloaded in background. The lets say the next day, I can get the file in a folder. Thanks guys take care!

    Hello guys thanks for your help so far. I have been off again on again with this task because its more for future purposes than anything.
    So far I have searched the net and stuff and decided that I will use WWW_LIST_TO_HTML since I want to download it the way it is. I am also going to use open/close dataset as many of you have mentioned.
    SO far Im just trying it out with a simple report program to see its funcitonalities. My code goes like this.
    <b>REPORT ZCCYT_COOL2 NO STANDARD PAGE HEADING LINE-COUNT 100 .
    DATA: IFIELDS TYPE TABLE OF W3FIELDS WITH HEADER LINE.
    *DATA: ihtml   TYPE TABLE OF w3html   WITH HEADER LINE.
    DATA: IHTML   TYPE TABLE OF W3_HTML  WITH HEADER LINE.
    DATA: BEGIN OF I_TAB OCCURS 0,
            MATNR LIKE MAKT-MATNR,
            MAKTX LIKE MAKT-MAKTX,
          END OF I_TAB.
    SELECT-OPTIONS: SO_MATNR FOR I_TAB-MATNR.
    SELECT MATNR MAKTX
      FROM MAKT
      INTO TABLE I_TAB
      WHERE MATNR IN SO_MATNR..
    LOOP AT I_TAB.
      WRITE: / I_TAB-MATNR,
               I_TAB-MAKTX.
    ENDLOOP.
    CALL FUNCTION 'WWW_LIST_TO_HTML'
       EXPORTING
           list_index = sy-lsind
         TABLES
              HTML       = IHTML.
    DATA: FILE TYPE LOCALFILE.
    FILE = '/usr/test.html'.
    OPEN DATASET FILE FOR OUTPUT IN BINARY MODE.
    LOOP AT IHTML.
      TRANSFER IHTML TO FILE.
    ENDLOOP.
    CLOSE DATASET FILE.</b>
    NOw the problem now though is that the file isnt downloading or saving at all. I cant seem to get what is wrong since the path does exist and the this seems the universal way to implement the program. Im guessing the problem lies in the file name, because everything seems to work fine. Hope to hear again soon sorry for not visiting this place sooner cuz I was buzy elsewhere.

  • Upload file without using file upload UI Element

    Hi all.
    I need upload a .txt file without using file upload UI Element because filename is not insert by user. The filename is generated by program. I try to use 'GUI_UPLOAD' and 'WS_UPLOAD' but don't work.
    Many thanks in advance.

    As you correctly pointed out we cannot use the gui_upload and gui_download fm's in webdynpro because they require sap gui and WD Components generally run in a HTML or Portal environment.
    The only option available is File Upload Element

  • Spaces are switching without user intervention

    I generally use 4 spaces and I've noticed on Mavericks apps will not stay ont he same space they are assigned too. I've also noticed designated spaces switching without any user intervention. For example "Desktop 3" and "Desktop 4" switch places and 4 will become 3 and visa versa. Has anyoen else encountered this?

    I am also experiencing problems where I lose a route and I get disconnected from the internet. I get it back by issuing a command:
    route get 192.168.2.1 (my wireless router)
    route get 192.168.1.254 (my DSL modem)
    However, I have no idea why this gets deleted in the first place.
    if you discover an answer please do post it here.
    Thanks,
    Ted

  • Events without user intervention

    I am developing a control application in which in open loop the user has interaction with controls in the GUI and a generation of events begin an action. However in closed loop the controller generates the values and rewriten the values at the controls in the GUI without intervention of user in the GUI. The events are not identified within the events loop located within the white loop. I am trying to work with Dynamically Registering Events but i am not have sucess. The specific question is how generated an event when a value control changes  without the intervention of the user in the GUI

    Use a property node for the front panel control and select the property
    "Value (Signaling)". When writing to this property, the event is
    triggered.

  • Events/without user intervention at the GUI

    I am developing a control application in which in open loop the user has interaction with controls in the GUI and a generation of events begin an action. However in closed loop the controller generates the values and rewriten the values at the controls in the GUI without intervention of user in the GUI. The events are not identified within the events loop located within the white loop. I am trying to work with Dynamically Registering Events but i am not have sucess. The specific question is how generated an event when a value control changes  without the intervention of the user in the GUI

    Gracias por utilizar los foros
    la solucion ya la tienes en esta liga
    http://forums.ni.com/ni/board/message?board.id=170&message.id=196808#M196808
    saludos
    Erwin Franz R.

  • How can I map a drive to Azue file shares without user intervention or having a user logged on?

    I have the file share created, and can manually map the drive. I have even created a batch file that will create the drive mapping.  One step further, I used the following regedit to create the mapped drive:
    Regedit:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
    add new string value:
    value name:  MapS
    value data:  c:\azurefileshare.bat
    I have a scheduled task running a batch file running the net use command, and the drive is available, and I can create/delete files, so access is not an issue.
    All works fine if I log onto the server, however, what I am trying to accomplish, is to have that drive mapped upon reboot without having a user log on.   Checking the log file running the net use command when no one is logged on, I get the following:
    Status       Local     Remote                    Network
    Unavailable  S:        path of file share
    Microsoft Windows Network
    The command completed successfully.
    New connections will be remembered.
    Is there a way to accomplish this?  Thanks in advance.

    Hello wdick,
    Thank you for your response and getting back on this issue. I am sorry that the blog that I referred to was not available. I pretty much thought that you must be referring to the ‘File Services’ which is in preview yet. I recently had another user with a similar
    question but currently, the users can access the files using only 'Interactive logon'. You can refer to this link: 
     http://social.msdn.microsoft.com/Forums/en-US/1f1fa9b5-a81d-4067-9d90-2c7c47667732/azure-file-services-authentication-without-prompt-passthrough?forum=windowsazuredata 
    Thanks.
    Syed Irfan Hussain

Maybe you are looking for

  • The copy/ paste function not working after OS 8 upgrade

    after OS 8 upgrade my iPad no longer works. It will not copy, then paste . The screen just starts scrolling up on its own. Very frustrating. Ipad Air worked perfectly prior to doing OS 8 install. This *****! Any ideas?

  • ASSIGN_TYPE_CONFLICT - /UI2/CL_LPD_UTILS=============CP

    Hi All Is anyone else experiencing a similar issues with the latest launchpad release? All tiles are working one day, and then a day later they were not.  A message would appear suggesting that the app configuration was incorrect. The Web Inspector i

  • Using s-video and my dislay

    I have a ATI Radeon 9000 pro in my G4. Is there any way I can use my tv as a second display using s-video. I don't want to use the TV at all time but only when watching videos and stuff. I currently have an old HP monitor using the VGA conection. Tha

  • Getting Active Directory Users in UCM User Admin - Users Tab

    Hello All We have integrated WLS with our Active Directory. And we are getting all the active directory users under Security Realms >myrealm >Users and Groups tab in WLS Console. We are also able to login to webcenter spaces and Content server using

  • Error in cursor for loop

    Hi  Guys , I am getting the below error in the following piece of code.I am using 11g.        L_SQL_TXT:='begin'||CHR(32)||       'for i in ( select '||l_col_list_1||', :in_tst_nm, :l_current_schema  from '||in_src_table||') LOOP         insert into