Using POST from an applet

Hi,
I need to connect to a URL from my applet and have the results show up in a new browser window. I have to use POST method since I need to submit a lot of parameters with the request. If I could have used GET method instead, this could have easily been accomplished using showDocument method. Even though applets can connect to a URL using POST, I could not locate any information on how to display the results in a new browser window. Anyone know how this can be accomplished?

To POST data to servlet :
- get data in applet by using getText() or getSelectedItem ...
- Open connection by URL class
- Open outputStream by BufferedWriter class
- Using write(String) to write data then close the tream
- to Receive data from servlet : getInputStream by BufferedReader class and then using readLine() to read data .
- Notice : you must make a protocol for your Applet and Servlet able to interface with it other
Good luck !

Similar Messages

  • How to use DOMParser from an Applet / Or, how to parse XML from an Applet?

    Hey,
    As stating in the subject line, I wonder how to do it without getting an �Access Denied� error.
    I would like to parse a XML file that has external DTD pointing to a SYSTEM location. Yes, I can change it to a public location. However, in either way, I have problems to use DOMBuilder to parse the xml file. The application always throws the security exception.
    I tried to use the DOMParser from org.apache.xerces.parsers to parse the xml file. I set the DOMParser to ignore parsing the external DTD, and use the DOMParser.parse(InputSource) to parse the xml file from a giving URL. However, I get null of the result document.
    Does anyone know how to parse the XML from an Applet? Or, does anyone know how to use the DOMParser from an Applet?
    Thank you very much,

    If the document resides on the local filesystem, you will need to sign a CAB or JAR for the applet to circumvent the sandbox's security restrictions. There are dozens of posts on how to do this. Basically, that will turn the applet into an application, from a Java security perspective.
    - Saish
    "My karma ran over your dogma." - Anon

  • Using JDBC from an Applet

    Hi,
    I'm trying to connet to an Oracle database from an Applet, using the oracle jdbc thin driver.
    When I'm running the applet with the applet viewer I can connet to the database. But, when I view the applet with Internet explorer 6 with the Microsoft JVM I get an exception:
    Error loading class: oracle.jdbc.driver.OracleDriver
    java.lang.NoClassDefFoundError
    java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
         at com/ms/vm/loader/URLClassLoader.loadClass(URLClassLoader.java)
         at java/lang/ClassLoader.loadClassInternal (ClassLoader.java)
         at java/lang/Class.forName (Class.java)
         at MyApplet.<init> (MyApplet.java:25)
         at com/ms/applet/BrowserAppletFrame.newInstance (BrowserAppletFrame.java)
         at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
         at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
         at com/ms/applet/AppletPanel.run (AppletPanel.java)
         at java/lang/Thread.run (Thread.java)
    I've tried to:
    1) Put the driver jar in the same place as the applet
    2) expand the jar in the applet's folder
    2) Add the jar to the archive attribute of the APPLET tag
    3) Add the applet and the content of the jar to a single arhcive
    but so far far nothing helped.
    Thanks,
    Dror B

    Hi,
    Did you try to use Sun's JVM? Microsoft VM is old, and probably does not contain the classes required by Oracle's driver; besides, it supports only old class format, which has evolved in Sun's JVM.
    Another solution is to use the RMI-JDBC driver by http://objectweb.org.
    Sincerely,
    Sergei Batiuk.

  • Using files from an applet

    Hello !
    I know it is impossible to write files from an applet for security reasons, but I "only" need to read some data from files.
    My applet works perfectly with the appletviewer, but when I try from IExplorer, it reacts as if the files were missing. In fact, I think it is a poblem with the location...where could I find the files ? What path do I have to mention in my code ?
    I tried to use a .jar archive, putting all my .class and data files in that archive, but it still doesn't find the data files.
    Thanks for you help.
    C14

    There's just as much security about reading files from an applet, otherwise a hidden applet on a web page could read the files on your PC and transmit your secrets to some web site.
    You [i[can[/i] write applets to read (and write) files on the local machine but they need to be digitally signed.
    If the files you want to read are just parameters etc. then the best thing is to put them where you put your html and read them through a URL connection. That's allowed.

  • Linking to external URL using POST from a button in APEX

    APEX Experts
    Does anyone know how to link to an external URL using POST rather than GET behind an APEX button? I'm pretty sure there must be a javascript call but I'm a real newbie to both APEX and Javascript.
    Also does anyone know why APEX decodes an encoded URL before sending it out and how to stop it?
    Thanks
    Deborah

    I did something similar recently but it was in .NET.
    Hopefully someone else here can help you do with Apex and Oracle. I am new to both.
    To POST instead of GET is not as easy as it sounds.
    What I did was open a new window where I outputted a dynamically created form. I would think that you would do that by using the pl/sql web toolkit to call a procedure and output the form using htp.p. You may also be able to do it with Apex (I think they are built using the same tech).
    Basically, your proc would look something like this:
    htp.p('<html><head>');
    htp.p('</head><body onload="document.FORM.submit();">');
    htp.p('<form name="FORM" method="POST" action="www.UrlToPostTo.com" >');
    htp.p('<input name="PostVar" type="hidden" value="' || MyValueToPost || '">');
    htp.p('</form></body></html>');
    So, it creates a html page with a form. When the page loads, it runs the javascript to submit the form to the other site. You can add in as many post items as you need. I marked them as hidden so that the user only sees a blank page briefly before the form is submitted.
    I am sure there is more to it than that, but it gives the general outline of how to post to another site dynamically. Hopefully someone else can fill in the rest.

  • Redirecting browser from an applet with POST

    Hi,
    How can I cause an applet to redirect a browser window using a POST request?
    Thanx,
    Yaron

    redirect using postIf you mean send a post request and let the http resonese redirect the page then
    you have 2 options.
    1.
    set values of html object from the applet (calling javascript):
    this.getAppletContext().showDocument(
                             new URL("javascript: someJSFunction('param','param');"));Submit the form from the applet calling javascript (see above).
    Note that I don't use JSObject since that one makes mozilla crash since jre 1.5
    2.
    Use URL and URLConnection to POST your data.
    Then use this.getAppletContext().showDocument() to navigate the the redirected URL (according to response from the URLConnection)
    Using POST:
    http://forum.java.sun.com/thread.jspa?threadID=645830&messageID=3816955
    3rd post

  • Call a Form using Webutil from the Menu loose focus on the applet

    Hello,
    I have the following problem:
    When calling a form using webutil from the menu the focus on the applet (I mean the Forms Application window) is lost and I have to click on the window to get back the focus on the application.
    Any advice ?
    Env: Forms 9i / Webutil 1.06
    Rgds,
    Philippe

    Try to use the NO_HIDE parameter in the CALL_FORM() built-in.
    Call_Form( 'the_form', NO_HIDE ) ;Or maybe, in the[b] When-New-Form-Instance trigger of the called form, return the focus to the calling form
    Go_Form( Get_Application_Property( CALLING_FORM ) ) ;Francois

  • Writing new HTML to a page from an applet using LiveConnect, 1.3.1 Plug-i

    Has anyone been able to successfully replace a page with an applet with the dynamically generated HTML from an applet using LiveConnect and Plugin 1.3.1 in Netscape 6.2 or IE?
    The following works fine without plugin or with 1.4.0 beta3 plugin.
    Here is the code that I use without plugin:
    JSObject windowObject = JSObject.getWindow(this);
    JSObject documentObject = (JSObject) windowObject.getMember("document");
    documentObject.call("close",null);
    documentObject.call("open",null);
    String anArray1[] = {null};
    anArray1[0] ="some HTML here";
    documentObject.call("write", anArray1);
    documentObject.call("close",null);
    Here is the code that I use with 1.4.0 plugin:
    JSObject windowObject = JSObject.getWindow(this);
    JSObject documentObject = (JSObject) windowObject.getMember("document");
    String anArray1[] = {null};
    anArray1[0] ="some HTML here";
    documentObject.call("write", anArray1);
    When I try to use anyone of the above using plugin 1.3.1, the browser either hangs or plugin generates runtime error. What is the correct way of writing to a document object? Or what is the way that works for 1.3.1 plugin?

    Hi,
    I am doing this in my applet to replace the page containing the applet with the new content. I tested that extensively with Netscape 4.7 and IE 5.5+. Definitely works if you are using Java Plug-In 1.3.1_02. Does not work well in Netscape 6.2.
        protected void setPageContent(final String newContent) {
            final JSObject window = JSObject.getWindow(this);
            final JSObject document = (JSObject) window.getMember("document");
            new Thread( new Runnable() {
                            public void run() {
                                document.call("clear", null);
                                document.call("write", new String[]{newContent});
                                try {
                                              document.call("close", null);
                                   } catch (JSException ignored) {
                        } ).start();

  • TS4268 How do I get facebook to say "posted from IPhone" when using my IPhone?

    When posting anything on facebook from my Iphone 4s. it tags as "posted from Mobile" how can I get it to say posted from Iphone. and yes I  downloaded the facebook app from the app store and when using the app it still says from posted from mobile. it would be nice to know that i spent alot of money for this phone, the least it can do is let my facebook friends know that i dont just have a mobile phone but an Iphone. Please HELP.

    This has nothing to do with Apple or the iphone.
    this is on the facebook developer, the posted from iphone was been removed a long time ago.  It now say IOS or mobile.
    If you don't like it I suggested you email the facebook app develper.

  • Re:Query for no.of days delayed using Receipt from production posting date.

    Dear SAP Experts,
    I need a query to calculate no of days delayed by using Receipt from production posting date and prod.order due date..i have already done the query but there is no link for joining the tables.Is there any link to join the tables..
    Plz Suggest a good query for this issue..
    With Regards,
    Revathy

    Dear Revathy,
    I think there is no need to link table if you just need calculate no of days delayed by using Receipt from production posting date and prod.order due date.
    You may check this query with the above:
    SELECT T0.ItemCode,T0.DueDate,
    T0.DocNum, T0.CloseDate,
    Datediff(dd,t0.DueDate,T0.CloseDate) Diff
    FROM dbo.OWOR T0
    WHERE  Datediff(dd,t0.DueDate,T0.CloseDate) > 0
    Thanks,
    Gordon

  • Sending XML messages from server to client using POST method

    Dear everyone,
    I have a simple client server system - using Socket
    class on the server side and URLConnection class on
    the client side. The client sends requests to the
    server in the form of an XML message using POST method.
    The server processes the request and responds with
    another XML message through the same connection.
    That's the basic idea.
    I have a few questions about headers and formats
    especially with respect to POST.
    1. In what format should the response messages from the
    server be, for the client? Does the server need to
    send the HTTP headers - for the POST type requests?
    Is this correct?:
       out.println("HTTP/1.1 200 My Server\r");
       out.println("Content-type: text/xml\r");
       out.println("Content-length: 1024\r");
       out.println("\r");
       out.println("My XML response goes here...");2. How do I read these headers and the actual message
    in the client side? I figured my actual message was
    immediately after the blank line. So I wrote
    something like this:
       String inMsg;
       // loop until the blank line is through.
       while (!"".equals(inMsg = reader.readLine()))
          System.out.println(inMsg);
       // get the actual message and process it.
       inMsg = reader.readLine();
       processMessage(inMsg);But the above did not work for me. Because I seem to
    be receiving a blank line after each header! (I suppose
    that was because of the "\r".) So what should I do?
    3. What are the different headers I must pass from
    server to the client to safeguard against every
    possible problem?
    4. What are the different exceptions I must be prepared
    for this situation? How could I cope with them? For
    example, time outs, IOExceptions, etc.
    Thanks a lot! I appreciate all your help!
    George

    hello,
    1) if you want to develop a distributed application with XML messages, you can look in SOAP.
    it's a solution to communicate objects distributed java (or COM or other) and it constructs XML flux to communicate between them.
    2) if it can help you, I have developed a chat in TCP/IP and, to my mind, when you send datas it's only text, so the format isn't important, the important is your traitement behind.
    examples :
    a client method to send a message to the server :
    public void send(String message)
    fluxOut.println(message);
    fluxOut.flush();
    whith
    connexionCourante = new Socket(lAdresServeur, noPort);
    fluxOut= new PrintWriter( new OutputStreamWriter(connexionCourante.getOutputStream()) );
    a server method in a thread to receive and print the message :
    while(true)
    if (laThread == null)
    break;
    texte = fluxIn.readLine();
    System.out.println(texte);
    that's all ! :)
    If you want to use it for your XML communication, it could be a good idea to use a special message, for example "@end", to finish the server
    ex :
    while(true)
    if (laThread == null)
    break;
    texte = fluxIn.readLine();
    // to stop
    if (texte.equals("@end"))
    {break;}
    processMessage(texte );
    hope it will help you
    David

  • Post parameters to a JSP from an applet

    Hello,
    Is there a way to send a post request to a JSP page from an applet ? Here is the scenario I am looking for :
    In Test.jsp, I invoke an applet. The applet should then do a POST request to the JSP. Currently, I am able to send a JSP request by appending parameters to the query string as
    getAppletContext().showDocument(new URL(getDocumentBase(),"Test.jsp?querystring")); in the applet. But this will be showing the parameters in the URL. I would like to have the parameters sent as "POST". I tried doing something like
    String data = "All URL encoded parameter names and values";
    URL postURL = new URL("Test.jsp");
    conn = (HttpURLConnection)postURL.openConnection();
    conn.setRequestMethod("POST");
    conn.setDoOutput(true);
    OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
    wr.write(data);
    wr.flush();
    wr.close();
    But how do I pass the control back to the JSP ? Any thoughts ?

    Thanks for all your responses. I posted the request and still couldn't get it working. Here is my code
    osDetection.jsp:
    <%@ page contentType="text/html; charset=UTF-8" %>
    <% // Get all the request parameters
    String userOSVersion = request.getParameter("osVersion") == null ? "" : request.getParameter("osVersion");
    String detect = request.getParameter("detect") == null ? "" : request.getParameter("detect");
    %>
    <% if(detect.equals("")) { %>
              <span>detect os version</span>
    <% } %>
    <%     if("os".equals(detect)) { %>
    <div align="center">
    <object width="250" height="75">
    <param name="type" value="application/x-java-applet" />
    <param name="code" value="Detection.class" />     
    <comment>
    <embed type="application/x-java-applet" code="Detection.class" width="1" height="2" />
    <noembed>No OS detected</noembed>
    </comment>
    </object>
    </div>     
    <% } %>
    OS Version: <%=userOSVersion%>
    Detect:          <%=detect%>
    Detection.java
    import java.applet.*;
    import java.io.OutputStreamWriter;
    import java.net.HttpURLConnection;
    import java.net.URL;
    import java.net.URLEncoder;
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    public class Detection extends Applet {
         public void init() {
              HttpURLConnection conn = null;
              try {
                   String data = "osVersion=" + URLEncoder.encode(System.getProperty("os.version"),"UTF-8");
                   URL postURL = new URL("http://localhost:8080/detection/osDetection.jsp");
                   System.out.println("posting to the url :");
                   conn = (HttpURLConnection)postURL.openConnection();
                   conn.setRequestMethod("POST");
                   conn.setDoOutput(true);
                   System.out.println("connection open");
                   OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
                   wr.write(data);
                   wr.flush();
                   wr.close();
                   // Get the response code
                   int code = conn.getResponseCode();
                   System.out.println("Response code of the object is "+code);
                   if (code==200) {
                   System.out.println("OK");
                   // Get the response
                   BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                   String line;
                   while ((line = rd.readLine()) != null) {
                   System.out.println(line);
                   rd.close();
                   conn.disconnect();
              } catch(Exception ex) {
                   System.out.println("Error:" + ex.getMessage());
    Am I missing something here ? I see the response being written to the Java console but how do I transfer the control back to JSP to do further processing in the JSP ?
    Thanks much in advance.

  • Best iPad apps for creating and sharing word and spreadsheet documents?  X-post from Using iPad

    I am about to take a work trip away for a few weeks and will need to create word and spreadsheet documents and share them with my colleagues back in the office. Does anyone have any tips on the best apps to do this? I'm concerned that the iWork apps might be problematic with the .pages and .numbers native formats, given that my colleagues work on ms office in a windows environment. Also, the google docs mobile experience seems to be pretty clunky, so I'm hoping someon out there has the perfect solution! Thanks in anticipation.
    (X-post from Using iPad, but thought I might get some useful responses here.)

    There is no perfect solution, especially for those who need to create more complex documents (tables, etc.) and spreadsheets.   If your files are simple Quickoffice will do the job; you can set up a shared dropbox for those at the home base to access and interact with it directly through the app.  For heavy duty lifting you may want to consider accessing your  work desktop remotely using Splashtop, Logmein, gotomypc app, etc...

  • Transfer posting from batch to batch using 309 or 311 issue

    Hi Experts,
    Need your help, I'm facing the following issue, I'm trying to transfer posting from batch to other batch using 309,
    Using MIGO
    the material, plant, storage location are the same but the batch number are different, I didn't get any message and when I save, there's nothing is changed, I checked the material document and found that the destination batch is same as source batch.
    Using MB1B
    the material, plant, storage location are the same but when I entered the source batch, the batch number is copied to the destination batch number and I got message  M7104 "stock to be removed from storage same as stock to be placed into the storage" and I can't change the destination batch number.
    Please advise how can I solve this issue or if there's any alternative way to transfer from batch to other by one step.
    Regards,
    Mohamed Mansour.

    You can well use 309 movement type in MIGO or MB1B and also you can well change the receiving batch number during the transaction..
    MB1B
    MIGO
    I think you can able to change the receiving batch.
    What the status of receiving batch shows in MIGO or MB1B ?
    Also check you field selection for movement type 311
    Go to OMBW, double click on 311, then double click on Transfer Posting
    It should be as optional entry.
    Then try again MB1B.
    Regards
    Dev

  • Activate a Midlet from an Applet

    Hi,
    I am trying to activate a Midlet from an Applet? Is this possible in any of the latest J2ME releases?
    Using SATSA I am able to send APDU commands from the Midlet to the Applet and start a scenario where my Applet and Midlet exchange information.
    Is this available in the opposite direction. I want that my Applet, when triggered by an event, be able to Activate\Wake Up the Midlet.
    I am a newbie to J2ME and after researching the web, still couldn't find an answer. Thanks for your help.
    Bye.

    You can communicate with servlet from an applet, using URL connection, and then send POST/GET methods through HTTP protocol, here is a code snippet,
    // applet side, this method will send a POST method to the servlet and then get url openstream to read a
    // returned object from the servlet, params should be in the form param1=value&param2=value etc...
    public Object getObjectFromServlet(String servletName,String params) {
        Object object = null;
        try {
          URL url = new URL(codeBase,
                            contextRoot + servletName + params);
          URLConnection con = url.openConnection();
          con.setUseCaches(false);
          InputStream in = con.getInputStream();
          ObjectInputStream result = new ObjectInputStream(in);
          object = result.readObject();
          result.close();
          in.close();
        catch (ClassNotFoundException ex) {
          System.err.println("ClassNotFoundException caught:" + ex.getMessage());
        catch (MalformedURLException ex) {
          System.err.println("MalformedURLException caught:" + ex.getMessage());
        catch (IOException ex) {
          System.out.println("IOException caught:" + ex.getMessage());
        return object;
    //servlet side
    public void doPost(HttpServletRequest request, HttpServletResponse response){
          //Extract all the necessary supplied parameters from the request object and configurations.
           String param1 = request.getParameter("param1");
           String param2 = request.getParameter("param2");
      try {
            ObjectOutputStream out = new ObjectOutputStream(response.getOutputStream());
            out.writeObject(object);
            out.close();
          catch (IOException ioe) {
            System.err.println("IOException caught:" + ioe.getMessage());
    }

Maybe you are looking for

  • Creating environment in solution manager 4.0

    I have been assigned to create a an environment within Solution Manager under Business Process however I do not know how to do this, can somebody please advice me on how to do this or refer me to the correct guide or CBT. Any help would be much appri

  • Hidden layers get PDFed anyway

    Hello all, I've been meaning to ask this for a while now: Whenever I hide InDesign layers; then Export to a PDF; and choose Visible Layers (in the General options); and finish up and OK the producing of the PDF; the dialog immediately warns me that s

  • Feature Request: Group episodes of a show in thumbnail view

    So I've bought a couple episodes of Battlestar Galactica from the iTunes Music Store, and I've been busily converting episodes of Robotech from DVD to mp4 files in my library. I like to view video files in the shiny "thumbnail" view (or whatever it's

  • E-recruiting start pages candidate selection

    Hi, Can anyone tell me how and when the column 'unread' is filled in the overview of the requisitions when you have chosen the entry 'candidate selection'. Kind regards, Ruth

  • Can't leave an infected site

    I landed on hxxp://getsecure.cz.cc/firefox-updates The page opens a dialog requesting to download an update. The dialog blocks all other interaction with ff. I can kill ff from the Windows Task Manager, but when I restart, the offending page opens as