Posting files with applet

Hello!
How can i post file to servlet with trusted applet?
Thank you!

Build a multipart request and send it that (easier to let html do it, but, hey, who am I to judge).

Similar Messages

  • How to configure the .ini file with applet

    hai
    i am using native methods in that methods they use some ip addresses. when i am using that native methods in applet run the applet using appletviewer tool it works fine but when i am open that applet using html page browser not configure that .ini file data .how to configure that .ini file with browser

    Hi Jay SenSharma,
    Thanks for your immediate response.
    I saw your URL links, But in your link give the recursive deployment using wlst. But my question is how to configure the oracle weblogic library files into Admin server & Managed Servers by using the wls.jar file through wlst script to create the new domain.
    But if create the new domain by using GUI mode then we manually give the admin server port number & managed servers port number and name.
    By default the library files are configured with the Admin server in GUI mode. But the Managed server the Library files are not configured with the Managed servers. Then we manually select all the library files to the corresponding managed servers. Then only the applications are deployed into the corresponding managed server.
    Regards,
    S.vinoth Babu

  • Using class files with applets

    I've converted a college project, a calculator, into an applet for a website resume. When the html file that loads the applet is opened on a machine with a JVM, the applet works fine. When I tested it on a machine that doesn't have a JVM, the applet wouldn't open.
    I'm assuming its because I'm using methods from classes such java.math, java.awt and java.awt.event. I wanted to try to include the neccessary class files into a .jar file that could be included into the archive attribute. Would this work? and also, where can I actually find these files so that I can put them into a jar file. For example, which directories would I look at to find them? I'm on Mac OS 10.3.7.
    Even with a search utility,I can't find the specific files with I'm looking for.
    Any help is greatly appreciated

    Hi,
    It doesn't matter that you have used classes in the packages java.math etc. The application will never run if there isn't a JRE installed for the web browser. I think most people usually puts a script on the html page which detects if a JRE is installed, and directs users to the download page if there is no JRE.
    Kaj

  • Saving a file with applets

    Hello my name is Lino and I'm Portuguese (sorry the bad English)
    I have a problem, I want to know how do save a .jpg file with the FileChooser and FileWriter, that is in the Server and I want to save a copy in my computer, but it must with Applets!
    Please help me
    Tanks
    LP

    Hi,
    because of security resons with applets, it is not possible to store an .jpg on your hard drive.
    Bernd

  • Writing in existing file with applet

    hi,
    i tried the following code after reading one of sun's tutorials:
    public void fWriteFile(){
              File f = new File(fileName);
              DataOutputStream dos;
              try{
                   dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(fileName)));
                   dos.writeChars(Lang1+";"+Lang2+";"+Lang3+";"+Lang4+";"+Lang5);
                   for(int i=0;i<wbVec.size();i++){
                        StringTokenizer lastTok = new StringTokenizer((String)wbVec.elementAt(i),";");
                        lastTok.nextToken();
                        lastTok.nextToken();
                        String deu = lastTok.nextToken();
                        String eng = lastTok.nextToken();
                        dos.writeChars(deu + ";" + eng + "\n");
                   dos.close();
              }catch(SecurityException se){
              }catch(IOException ioe){
    and now i am confused since the apllet just doesnt write anything in the ... file

    it's a dictionary, i read the entries from and in case
    some changes were made they need to be saved... as far
    as i knew the applet had rights on a local system but
    not over the web...Nope. Think about it... What if someone wrote a malicious applet, and put it on the web. Then you go to their site, and they trash your file system.
    You'd have to make the applet a "trusted" one to do that, though I'm not here to answer questions about how that's done. Search the forum or other sites.

  • SecurityException: Unable to create temporary file with applet

    My applet tries to write a temp file
    try {
              File temp = java.io.File.createTempFile("student", ".log");
              strFilename = temp.getAbsolutePath();
    } catch (IOException e1) {
              e1.printStackTrace();
    }But when I run, it throws an exception:
    java.lang.SecurityException: Unable to create temporary file
    I tried to sign the applet, as to http://www.developer.com/java/data/article.php/3303561 but it's still the same.
    There's another way: using java.policy,
    grant {
      permission java.security.AllPermission;
    };but it seems to be not very gentle. Could you show me the solution please? Thanks in advance.
    Cheers,

    Yes, that's what I found. Here is the summary to do it, hope it helps someone else:
    1. Create key for signed jar:
    keytool -genkey -keystore abc.com -keyalg rsa -dname "CN=Abc, OU=Def, O=GHI, L=KLMN, ST=OP, C=XY" -alias TheCert -validity 3600 -keypass password -storepass password2. Make jar file
    3. Sign the jar file
    jarsigner -keystore abc.com -storepass password -keypass password -signedjar SignedAppletTest.jar OrgAppletTest.jar TheCertIt works for me.
    I'd like to thank harmmeijer and everyone who interests.
    Cheers,

  • Posting file with ClientHTTPConnection

    Hi,
    I have been trying to upload a file using the HTTP post method for, and the ClientHTTPRequest class made available on the web at:
    http://www.devx.com/Java/Article/17679/0/page/3
    by its author, for more than a day. I am calling post, but the file is not being posted. The file should, according to the doc, be attached by act of using a the setRequestParameter method for a file value. No luck please help.
    The relevant portion of my code is:
    req.setParameter("Filename", testFile );
    req.setParameter("Content-Type:", "multipart/form-data; boundary=" + req.boundary);
    req.setParameter("Content-disposition", "form-data; name=\"Log\"; filename=C:\\finalFile.txt");
    InputStream is = req.post("filename", testFile);
    Thanks,

    Please ignore.
    The problem turned out to be a server side issue. I was writing the client, and the people on the server side were blaming me. Of course, I've been the one blaming other people for my mistakes often enough, so I guess it evens out.
    Good luck and thanks for looking at this.

  • Trying to Imitate the html POST  method with an applet

    I am trying to imitate the POST method with an applet, so that I can eventually send sound from a microphone to a PHP script which will store it in a file on a server. I am starting out by trying to post a simple line of text by making the PHP script think that it is receiving the text within a POST-ed file. The reason I am doing things this way is in part because I am, for the time being, limited to a shared server without any support for servlets or any other server side java.
    The code I am trying is based in part on an old thread found elsewhere in this forum, concerning sending data to a PHP file by imitating the POST method:
    link:
    http://forum.java.sun.com/thread.jspa?threadID=530399&messageID=2603608
    someone named "harmmeijer" provided most of the answers on that thread. If that person is still around hope they take a look at this,also I have some questions to clarify what they said on the other thread..
    My first attempt at code is below. The applet is in a signed jar file and is trying to pass a text line to the PHP script in the same directory and on the same server that the applet came from. It is doing this by sending header information that is supposed to be identical to what an html form would send if it was uploading a .txt file with the line of text within it. The applet displays one button. When you press it, it sucessfully starts up the postsim method (defined at the end), which is supposed to send the info to the PHP script at the server.
    I have two questions:
    1) I know that the PHP script is starting up, because it prints out a few messages depending on what happens. However, the script does not recognize any file coming down the line, so it does not save anyting on the server, and prints out a message saying the no file was uploaded.
    Any idea what might be going wrong? I'm not getting any error messages from the applet. I've tried a few different variations of the 'header' information contained in the line:
    osToServer.writeBytes("--****4353\r\nContent-Disposition: form-data; name=\"testfile\"; filename=\"C:testfile.txt\"\r\nContent-Type: text/plain\r\n");
    The commented out line below it shows one variation (which was given in the thread mentioned above).
    2) You'll notice that I've commented out the two lines having to do with the input line:
    //InputStream isFromServer;
    and
    //isFromServer = uc.getInputStream();
    The reason is that the program crahes whenever I put the latter line in - to the extent that Opera closes down the JVM and then crashes when I tried to exit it.. I must be doing something horribly wrong there! I first tried using isFromServer = new DataInputStream(uc.getInputStream());
    becuase it was consistent with the output stream, but that caused the same problem.
    Here's the code:
    public class AudioUptest1 extends Applet{
    //There are a few spurious things defined in this section, having to do with the fact the microphone data is evenuatly going to be sent. haven't yet insterted code to get input from a microphone.
    AudioFormat audioFormat;
    TargetDataLine targetDataLine;
    SourceDataLine sourceDataLine;
    DataOutputStream osToServer;
    //InputStream isFromServer;
    URLConnection uc;
    final JButton captureBtn = new JButton("Capture");
    final JPanel btnPanel = new JPanel();
    public void init(){
    System.out.println("Started the applet");
    try
    URL url = new URL( "http://www.mywebsite.com/handleapplet.php" );
    uc = url.openConnection();
    //Post multipart data
    uc.setDoOutput(true);
    uc.setDoInput(true);
    uc.setUseCaches(false);
    //set request headers
    uc.setRequestProperty("Connection", "Keep-Alive");
    uc.setRequestProperty("HTTP_REFERER", "http://applet.getcodebase");
    uc.setRequestProperty("Content-Type","multipart/form-data; boundary=****4353");
    osToServer = new DataOutputStream(uc.getOutputStream());
    //isFromServer = uc.getInputStream();
    catch(IOException e)
    System.out.println ("Error etc. etc.");
    return;
    //Start of GUI stuff
    captureBtn.setEnabled(true);
    //Register listeners
    captureBtn.addActionListener(
    new ActionListener(){
    public void actionPerformed(
    ActionEvent e){
    captureBtn.setEnabled(false);
    //Postsim method will send simulated POST to PHP script on server.
    postsim();
    }//end actionPerformed
    }//end ActionListener
    );//end addActionListener()
    add(captureBtn);
    add(btnPanel);
    // getContentPane().setLayout(new FlowLayout());
    // setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(250,70);
    setVisible(true);
    }//end of GUI stuff, constructor.
    //These buffers might be made larger.
    byte tempOutBuffer[] = new byte[100];
    byte tempInBuffer[] = new byte[100];
    private void postsim(){
    System.out.println("Got to the postsim method");
    try{
    //******The next four lines are supposed to imitate a POST upload from a form******
    osToServer.writeBytes("--****4353\r\nContent-Disposition: form-data; name=\"testfile\"; filename=\"C:testfile.txt\"\r\nContent-Type: text/plain\r\n");
    //osToServer.writeBytes("Content-Disposition: form-data; name=\"testfile\"; filename=\"C:testfile.txt\"\r\nContent-Type: text/plain\r\n");
    //This is the text that's cupposed to be written into the file.
    osToServer.writeBytes("This is a test file");
    osToServer.writeBytes("--****4353--\r\n\r\n");
    osToServer.flush();
    osToServer.close();
    catch (Exception e) {
    System.out.println(e);
    System.out.println("did not sucessfully connect or write to server");
    System.exit(0);
    }//end catch
    }//end method postsim
    }//end AudioUp.java

    Hi All,
    I was trying to write a signed applet that helps the
    user of the applet to browse the local hard disk and
    select a file from the same. The JFileChooser class
    from Swing is what I used in my applet. The problem
    is with the policy file. I am not able to trace the
    exact way to write a policy file which gives a total
    access to read,write,delete,execute on all the drives
    of the local hard disk.
    I am successful in signing the applets and performing
    operations : read,write,delete & execute on a single
    file but failing to grant permission for the entire
    file.
    Any help would be highly appreciated.Which policy file are you using? there might be more than one policy file.
    also, u have to specify the alias of the signed certificate in the policy file to grant the necessary priviledges to the signed applet.

  • Transferring files from users mashines on the server. Uploading with applet

    I'm trying to create applet that would do uploading of user file on the server.
    I'm woundering, Is there any ways to use java applet to open a file on user mashine into a stream and transfer it thought socket into
    server? Is there any good solution that do uploading with java applet? (I can't use CGI or PHP)
    I just noticed that applets don't support FileInputStream. How could I in general get information from user file?
    Ok. Thanks for ideas that you gave me. But there are useless. All that I can use is only HTTP. Unfortunately no FTP, no Web Start application.
    looking for help

    well, i don't work a lot with applets because of their inherent limitations. but my guess would be that you have to somehow use a signed applet. of course that doesn't help with the FileInputStream problem you are talking about.
    if i were going to do it and i couldn't use FTP, i'd write a WebStart app that calls servlets (sending it byte arrays) and the servlets will construct the files on the server...
    i have no clue how you are going to do what you want...

  • HTTP POST Request with XML file in

    Hi @ all,
    I would like to send an HTTP Request with an XML File in the body to an SAP System
    I have the target URL and the a XML File.
    Now the question is. Is it possible to use something like the HTTP_POST FuBa to send an url post request with an xml file?
    If yes can anybody give me a hint?
    I have a php script which exactly do this coding. But to integrate it all in one system it is necessary to transform it into ABAP and call it there.
    // compose url and request and call send function
    function test($productID, $categoryID) {
         // create url
         $PIhost = "XXX.wdf.sap.corp";
         $PIport = "50080";
         $PIurl = "/sap/xi/adapter_plain";
         $PIurl .= "?sap-client=800";
         $PIurl .= "&service=XXX";
         $PIurl .= "&namespace=XXX";
         $PIurl .= "&interface=Frontend_Interface";
         $PIurl .= "&qos=EO";
         $PIurl .= "&sap-user=XXX";
         $PIurl .= "&sap-password=XXX";
         // create xml
         $request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
         $request .="<n1:FrontendInbound_MessageType xmlns:n1=\"http://crmpiebay.com\">\n";
         $request .= "\t<FrontendInbound>\n";
         $request .= "\t\t<ProductName/>\n";
         $request .= "\t\t<ProductCategory>".$categoryID."</ProductCategory>\n";
         $request .= "\t\t<ProductID>".$productID."</ProductID>\n";
         $request .= "\t\t<MessageID/>\n";
         $request .= "\t</FrontendInbound>\n";
         $request .= "</n1:FrontendInbound_MessageType>";
         // send http request
         postToHost($PIhost, $PIport, $PIurl, $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"]."/".$_SERVER["PHP_SELF"], $request);
    // send post request to PI server
    function postToHost($host, $port, $path, $referer, $data_to_send) {
      $fp = fsockopen($host, $port);
      if($fp) {
           $res="";
           fputs($fp, "POST $path HTTP/1.1\r\n");
           fputs($fp, "Host: $host\r\n");
           fputs($fp, "Referer: $referer\r\n");
           fputs($fp, "Content-type: text/plain\r\n");
           fputs($fp, "Content-length: ". strlen($data_to_send) ."\r\n");
           fputs($fp, "Connection: close\r\n\r\n");
           fputs($fp, $data_to_send);
           while(!feof($fp)) {
               $res .= fgets($fp, 128);
           fclose($fp);
           return $res;
    Would be great if anybody could give me a hint how to solve such a HTTP Post request with XML body data.
    Thanks in advance.
    Chris
    Edited by: Christian Kuehne on Feb 26, 2009 4:32 PM

    hi friend could you please share your solution regarding this query if u got it already?

  • File Sharing with Applets

    I am new to Java and applets in general so bear with me. I am wondering if it is possible to share files files between two clients via applets running in their browsers. From what i understand the 2 applets cannot directly connect but would it be possible with help from some sort of servlet? I noticed a very intriguing applet called bitlet (www.bitlet.org) that allows for a java applet to become an agent for bit torrenting. I am looking for similar capabilities except more direct between 2 specific clients.
    Is this possible? And if so where should I begin?
    I have developed a model that routes all files through the server but i am looking to conserve bandwidth through the use of this peer to peer network.

    As you are running Swing, I assume your applet is using the JAVA2 plattform.
    You can easily set up a policy file which defines the appropriate permissions necessary for your applet requires to wok.
    When deploying your applet, you can offer the download of that policy file to your users so that they can put it in their home directory as .java.policy
    You can read about policy files and applet restrictions at
    http://java.sun.com/docs/books/tutorial/security1.2/tour2/
    This should answer most of your questions.
    Oliver

  • Can someone help with a previous post labeled "Writing to a data file with time stamp - Help! "

    Can someone possibly help with a previous post labeled "Writing to a data file with time stamp - Help! "
    Thanks

    whats the problem?
    Aquaphire
    ---USING LABVIEW 6.1---

  • Will somebody please post an Aperture-written xmp file *with* custom metadata in it - thanks.

    It is my understanding that Adobe's migration tool will NOT support transferal of custom metadata from Aperture to Lightroom.
    I have recently enhanced my Custom Metadata plugin to read custom metadata from Expression Media xmp, and it seems like a no-brainer to have a "preset" which can read/import/transfer custom metadata from Aperture xmp too - I just need a sample to work with - thanks.
    If you don't want to post here, please send directly to me.
    robcole.com - Contact Me
    Rob

    To attempt a wrap-up for this thread:
    Aperture does NOT provide a means to save custom metadata in XMP - the initial premise of this thread was incorrect: a thank you to John Beardsworth for setting me straight. Specific question asked has been answered.
    The purpose for the thread however was to learn how to get information out of Aperture so it can be gotten into Lightroom (final destination: custom metadata fields).
    Here is one way to get custom metadata in Aperture to custom metadata in Lightroom, recommended if you have enough free IPTC fields to house the custom data temporarily:
    * Create an applescript file with the following contents, modified to support your custom metadata fields; note: it must also be modified to specify the IPTC fields to be used:
    tell application “Aperture”
        set imageSel to the selection
        repeat with i from 1 to count of imageSel
            tell library 1
                tell item i of imageSel
                    set customFieldValue to value of custom tag "myCustomFieldName"
                    set value of IPTC tag "myFreeIptcFieldName" to customFieldValue
                end tell
            end tell
        end repeat
    end tell
    Note: you must adapt script depending on your custom fields, and which IPTC fields you have free.
    * Select photos in Aperture.
    * Execute the script.
    * Once photos are in Lightroom, with IPTC fields populated.., then in Lr's plugin manager, with 'Custom Metadata' plugin selected, click 'Transfer Metadata' button, then "follow the yellow-brick road" (you will be prompted with instructions..). Metadata will be transferred from IPTC fields to custom metadata in Lightroom.
    If you do NOT have sufficient IPTC fields to use, or would rather not use IPTC fields for this, then you'd have to modify the script to populate a row in a CSV file for each photo, then use the 'Import from CSV' function in Custom Metadata plugin. I can help if it comes to this..
    PS - There may be other ways as well, but maybe this is enough..
    Rob

  • Upload a file with an Applet

    Hi,
    I want to know if it's possible to upload a file with an Applet, but not a signed Applet.
    Thanks
    Cris

    Yes, but you are limited to uploading to the server from where the applet was originating from.
    Regards,
    Peter Norell

  • JAR Files and Applets with Java Plug-In

    This seems to be a basic question, but I can't figure it out! I have a jar file that contains all my class files for my applet. The jar file is in the same directory as the following html file:
    <html>
    <body>
    <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    WIDTH = 700 HEIGHT = 510 codebase="http://java.sun.com/products/plugin/1.3.1/jinstall-131-win32.cab#Version=1,3,1,0">
    <PARAM NAME = ARCHIVE VALUE = "myFiles.jar" >
    <PARAM NAME = CODE VALUE = "MainView.class" >
    <PARAM NAME="type" VALUE="application/x-java-applet;jpi-version=1.3.1">
    <PARAM NAME="scriptable" VALUE="false">
    </OBJECT>
    </body>
    </html>
    I've checked the jar file, it's the same name. MainView.class is most certainly in the jar file - yet everytime I open the page up, I get the class not found error:
    java.lang.ClassNotFoundException: java.io.FileNotFoundException
    MainView.class (The system cannot find the file specified)
    If I don't jar the files, the applet works fine - but I want to jar them as it's some 20 class files. What am I doing wrong?

    I've had a similar problem where it pops up the Java Extension Installation window, and starts downloading. Everything appears normal, but when it tries to run the applet it gets "load: class <className> not found" where <className> is the name of the class in my CODE parameter.
    It appears that on occasion the download of the jar gets cut off. When I searched the browser's cache, I find a jar file that has fewer bytes than it should. In order to initiate a retry, you have to delete the jar file from your browser's cache, close all your browser windows so that the Plug-in with its truncated jar file stops running, and load the HTML page again. It appears that it checks the timestamp of the jar file in your cache and the one on the server and decides that it doesn't need to download it again. But if you delete it from your cache, it forces a retry.
    I never have this problem when I open from my hard drive. I've never had the problem with a cable modem connection. I've had it once from a corporate LAN hitting an internet server (ie., outside corporate WAN). I've had people report the problem with dial-up connections. My theory is that whatever Sun is using to download the applet is more sensitive than either HTTP download or FTP.
    Has anybody else experienced this problem? Is there anything you can do about it? I couldn't find a bug report on it. Is there one?

Maybe you are looking for

  • IPod nano won't show up on iTune

    I got a new iPod nano 4GB (3G) last week and it worked fine for a while. Yesterday, I installed a new DVD burner and drivers (Memorex) in my computer and now, my iPod won't show up on iTunes. It says: "The software required for communicating with the

  • Print from  Windows XP to a shared Mac printer

    My Mac is using OS 10.3.9 and I want to share my ML-1210 with a PC. I attempted to use CUPS but the PC claims the ML-1210 cannot be "shared". Is there a step-by-step process for sharing a Mac printer with a PC? Thanks. 1) I have installed the latest

  • Thumbnails in Organizer are already corrected?

    The thumbnails in the organizer seem to be corrected for color, brightness, etc.  For example...three bracketed exposures of the same scene appear as identical thumbnails in the Organizer. I would like to see exactly what I shot. I cannot find a pref

  • Links in Hotmail emails don't open in new tab

    Someone apparently made changes in about:config settings. I opened my home page MSN and when I clicked on Hotmail link, the Hotmail sign in page opened in a new tab. Previously when I clicked on teh Hotmail link on MSN home page, the sign in page wou

  • Missing pdfjam binaries from texlive-bin

    Hello, with # pacman -S pdfjam pacman installs texlive-bin but this package is missing the pdfjam and pdfjoin executables. The man pages are there, though: $ pacman -Ql texlive-bin | grep 'pdfjam\|pdfjoin' texlive-bin /usr/share/man/man1/pdfjam-pocke