How to send results to actionscript using java

Hi,
I do RPC using HttpService.
In my situation, I need to send results from Java code to
Flex Action script. I have defined a Java Servlet receiving data
from Flex application, then it processes with the data, finally the
Servlet is supposed to send some feedbacks to the client(Flex).
My question is that how can I define codes in doPost() method
that the following function will get "result" from the Java side.
public static function httpResult(event:ResultEvent):void
var result:Object = event.result;
//Do something with the result.
if (result.toString() == "success")
resultMessage.text = "Login Success";
resultMessage.text = "Invalid User";
}

Hi,
Try this: If you are sending a simple text as "sucess" or
"error" after doing some process in the servlet..
set your content type to "text/plain" and simply
println(<data to be sent>);
In the flex application, get the result text that the servlet
send using:
resultString = String(httpUrl.lastResult);
where httpUrl is the id of the HTTPService. Now you can
compare what the servlet send by:
if(resultString=="sucess") {
Hope this solves your problem :)
Regards,
-- Abdel Olakara
http://olakara.googlepages.com
http://technopaper.blogspot.com

Similar Messages

  • How to send results to actionscript using java via HttpService

    Hi,
    I do RPC using HttpService.
    In my situation, I need to send results from Java code to
    Flex Action script. I have defined a Java Servlet receiving data
    from Flex application, then it processes with the data, finally the
    Servlet is supposed to send some feedbacks to the client(Flex).
    My question is that how can I define codes in doPost() method
    that the following function will get "result" from the Java side.
    public static function httpResult(event:ResultEvent):void
    var result:Object = event.result;
    //Do something with the result.
    if (result.toString() == "success")
    resultMessage.text = "Login Success";
    resultMessage.text = "Invalid User";
    }

    I advise having your servlet build an xml string, maybe put a
    status attribute in the root tag, like this:
    <myroot status="success">
    <mytext>Some text</mytext>
    </myroot>
    and return that to the calling Flex client. XML is easier to
    work with than Object. On the HTTPService tag, set
    resultFormat="e4x", and it will return plain XML.
    then in the handler, do:
    var xmlResult:XML = XML(event.result); //this will already be
    the myroot node
    //Do something with the result.
    if (xmlResult.@status== "success") //reads the status
    attribute
    resultMessage.text = xmlResult.mytext.text(); //get the
    value of themytext text() node
    resultMessage.text = "Error";
    Tracy

  • How to send HTML Format Mail using Java Mail in oracle 9i Forms

    Dear All
    could you please tell me how to send HTML Format Mail using Java Mail in oracle 9i Forms and how to implement the java mail ?
    if it is possible, could you please send me the sample code? please very urgent
    Thanks
    P.Sivaraman

    Hello,
    <p>Here is a Form sample.</p>
    Francois

  • How to send a https request using jsf

    hi
    Can anybody tell a sample how to send a https request using JSF ...
    thanks

    Prefix the request URI with the https protocol.
    The answer is too easy and straightforward that I guess that you mean something else. If you just want to know how to configure an SSL environment for your own webapplication, refer to the Java EE tutorial chapter 28: http://java.sun.com/javaee/5/docs/tutorial/doc/

  • Can any one please send me sample programs using java mapping..

    <b>Can any one please send me sample programs using java mapping with input and output?</b>
    please let me know how to get started with java mapping?
    Prerequisites for java mapping ?
    What are the jars need to be deployed for SAX,DOM.  And how to do it in NWDS?
    Use of Execute() and setparameter() ... StreamTransformation?
    Some sample program using java mapping with simple logic(input and output)?

    Hi,
    Did you go thro these blogs?
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-i
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-ii
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-iii
    Nice blogs to start Java Mapping.
    Go thro this one too.
    /people/stefan.grube/blog/2006/10/23/testing-and-debugging-java-mapping-in-developer-studio
    Regards,
    P.Venkat
    Message was edited by:
            Venkataramanan

  • How to do SAVE AS DRAFT using java mail api

    Hello,
    I want to know how to do SAVE AS DRAFT using Java mail Api.
    thanks

    Hello,
    I want to know how to do SAVE AS DRAFT using Java
    mail Api.
    thanksI don't think you can. That sounds like a feature of a mail client app itself. The Java mail API is for when you're ready to actually send the thing. Saving drafts is storing them somewhere like you would any other data; nothing to do with the mail API.

  • How to get the context data using java script in interactive forms

    Hi All,
    How to get the context data using java script in interactive forms by adobe,  am using web dynpro java
    thanks.

    Hi venkat,
    Please Refer this link.
      Populating one Drop-Down list from the selection of another Drop-down list
    Thanks,
    Raju.

  • How to read a text file using Java

    Guys,
    Good day!
    Please help me how to read a text file using Java and create/convert that text file into XML.
    Thanks and God Bless.
    Regards,
    I-Talk

         public void fileRead(){
                 File aFile =new File("myFile.txt");
             BufferedReader input = null;
             try {
               input = new BufferedReader( new FileReader(aFile) );
               String line = null;
               while (( line = input.readLine()) != null){
             catch (FileNotFoundException ex) {
               ex.printStackTrace();
             catch (IOException ex){
               ex.printStackTrace();
         }This code is to read a text file. But there is no such thing that will convert your text file to xml file. You have to have a defined XML format. Then you can read your data from text files and insert them inside your xml text. Or you may like to read xml tags from text files and insert your own data. The file format of .txt and .xml is far too different.
    cheers
    Mohammed Jubaer Arif.

  • How to send images through PI using SOAP adapter

    hi,
    Can anybody tell me how to send images through PI using SOAP adapter.
    Regards ,
    Loveena

    Hi Loveena,
    only as attachments of a SOAP message.
    Regards,
    Udo

  • How to create a packet by using java?

    Hi, i am currently working on a research and i have some problems here.
    1) how to create a packet by using java programming ?
    2) How can i set the packet's information (e.g: packet's length, size of its header, etc) by using java?
    I am currently in a midst of this now and i hope that someone is willing to correspond to my questions and help me out of it.
    Thank you!

    I wan to create a customize packet where the user can
    define the header size, the packet's length etc. in
    the program......Then you get to write it to the connection yourself. Look at the OutputStream classes to see how to write low level output to a connection.

  • How to store images in database using java

    hii
    how to store images in database using java..........
    Message was edited by:
    naveennaga

    I asked a similar question once and the answer I got was - Don't.
    Instead, store the images on a drive somewhere and store the path in the database.
    But I'm no expert - that's just what I was told by someone who does this kind of stuff a lot.
    Hope that helps.

  • How to check & unzip zip file using java

    Dear friends
    How to check & unzip zip file using java, I have some files which are pkzip or some other zip I want to find out the type of ZIp & then I want to unzip these files, pls guide me
    thanks

    How to check & unzip zip file using java, I have
    ve some files which are pkzip or some other zip I
    want to find out the type of ZIp & then I want to
    unzip these files, pls guide meWhat do you mean "other zip"? Either they're zip archives or not, there are no different types.

  • How to Play a sample sound using Java

    Hi,
    I have an mp3 music files in database. When a user chooses a particular button, all the songs are fetched from the database.
    I have two buttons namely, 'Buy' and 'Play Sample'. If I click the 'Play Sample' button, a sample of the song has to be played (not the full song). If the user likes the sample, he can buy the full song.
    My question is how to achieve the 'Play Sample' using Java Swings and Sound. I have googled, but not find any solutions. Please provide me an example or link.
    Thanks in advance.

    HI
    Actually i am trying to create a JFrame which plays an mp3 music file
    with the help of play and stop buttons in it ...
    i splitted the frame into two
    i want a music file list in the first frame (JComboBox)
    and want to have play and stop button in the second frame .
    i had tried out some code in which the frame part is fine ,,,
    but i am not knowing how to play the file with those buttons ...
    here is the code and plz help me to move further ...
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JSplitPane;
    public class AudioFile extends JFrame {
        public AudioFile() {
            setTitle("Music File");
            setSize(300, 400);
            JPanel jp1 = new JPanel();
            JPanel jp2 = new JPanel();
            JButton s= new JButton("STOP");
            JButton p= new JButton("PLAY");
            JLabel j1 = new JLabel("MusicFile");
            String[] musicfiles={"file:///home/swathi/Desktop/spot3.mp3","anitha.mp3"};
            JComboBox musiclist=new JComboBox(musicfiles);
            musiclist.setSelectedIndex(1);
            jp1.add(j1);
            jp1.add(musiclist);
            jp2.add(s);
            jp2.add(p);
            JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
                    true, jp1, jp2);
            splitPane.setOneTouchExpandable(true);
            getContentPane().add(splitPane);
        public static void main(String[] args) {
          AudioFile sp = new AudioFile();
            sp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            sp.setVisible(true);
    }

  • Sending an e-mail using java

    Hi,
    I am sending an e-mail using java. It works fine, but I wanted to know if there is any possibility to attach a document, without using a File object. Because I have to write the File object and then delete it at the end. I would like to know if I can use for example a byte [], or something else.
    Thank you very much.
    This is my code, if that helps.
    public static void sendWithAttach(String p_sender, String p_receiver, String p_subject,
    String p_comment, int p_nombrePiecesJoints, HashMap<String, byte[]> p_files) {
    Properties props = System.getProperties();
    props.put("mail.smtp.host", Solapcore.getCurrent().getServletConfig().getServletContext().getInitParameter("SMTP"));
    Session session = Session.getDefaultInstance(props, null);
    MimeMessage sender = new MimeMessage(session);
    MimeBodyPart mbp1 = new MimeBodyPart();
    Multipart mp = new MimeMultipart();
    List<File> listeFiles = new ArrayList<File>();
    try {
    //On assigne to, from, subject, body, priority
    sender.setRecipients(javax.mail.Message.RecipientType.TO,
    InternetAddress.parse(p_receiver, false));
    sender.setFrom(new InternetAddress(p_sender));
    sender.setSubject(p_subject);
    mbp1.setText(p_comment);
    //sender.setPriority(0);
    mp.addBodyPart(mbp1);
    //On attache les documents
    for(Map.Entry<String, byte[]> entry : p_files.entrySet()) {
    MimeBodyPart mbp2 = new MimeBodyPart();
    String fileName = entry.getKey();
    byte [] dataFile = entry.getValue();
    File file = new File(fileName);
    FileOutputStream fos = new FileOutputStream(file);
    fos.write(dataFile);
    mbp2.attachFile(file);
    mbp2.setFileName(fileName);
    mp.addBodyPart(mbp2);
    listeFiles.add(file);
    sender.setContent(mp);
    Transport.send(sender);
    }catch(MessagingException mex) {
    mex.printStackTrace();
    }catch(FileNotFoundException fnf) {
    fnf.printStackTrace();
    }catch(IOException ioe) {
    ioe.printStackTrace();
    }finally {
    Iterator<File> itListeFiles = listeFiles.iterator();
    while(itListeFiles.hasNext()) {
    File tempFile = (File)itListeFiles.next();
    tempFile.delete();
    }

    Thank you very much.
       public static void sendWithAttach(String p_sender, String p_receiver, String p_subject,
          String p_comment, int p_nombrePiecesJoints, HashMap<String, byte[]> p_files) {
        Properties props = System.getProperties();
        props.put("mail.smtp.host", Solapcore.getCurrent().getServletConfig().getServletContext().getInitParameter("SMTP"));
        Session session = Session.getDefaultInstance(props, null);
        MimeMessage sender = new MimeMessage(session);
        MimeBodyPart mbp1 = new MimeBodyPart();
        Multipart mp = new MimeMultipart();
        List<File> listeFiles = new ArrayList<File>();
        try {
          //On assigne to, from, subject, body, priority
          sender.setRecipients(javax.mail.Message.RecipientType.TO,
              InternetAddress.parse(p_receiver, false));
          sender.setFrom(new InternetAddress(p_sender));
          sender.setSubject(p_subject);
          mbp1.setText(p_comment);
          //sender.setPriority(0);
          mp.addBodyPart(mbp1);
          //On attache les documents
          for(Map.Entry<String, byte[]> entry : p_files.entrySet()) {
            MimeBodyPart mbp2 = new MimeBodyPart();
            String fileName = entry.getKey();
            byte [] dataFile = entry.getValue();
            File file = new File(fileName);
            FileOutputStream fos = new FileOutputStream(file);
            fos.write(dataFile);
            mbp2.attachFile(file);
            mbp2.setFileName(fileName);
            mp.addBodyPart(mbp2);
            listeFiles.add(file);
          sender.setContent(mp);
          Transport.send(sender);
        }catch(MessagingException mex) {
          mex.printStackTrace();
        }catch(FileNotFoundException fnf) {
          fnf.printStackTrace();
        }catch(IOException ioe) {
          ioe.printStackTrace();
        }finally {
          Iterator<File> itListeFiles = listeFiles.iterator();
          while(itListeFiles.hasNext()) {
            File tempFile = (File)itListeFiles.next();
            tempFile.delete();
        }

  • How can we prevent back button  using java script

    how can we prevent back button using java script

    Would be quicker for you to google for javaScript
    javascript:window.history.forward(-1);

Maybe you are looking for

  • How to create a secure photo gallery in Muse or other options?

    I am looking at working with a phtotographer and she would like to have a secure (require login) photo gallery for her clients and also she wants to be able to upload these photos. I would like to know what the options are to do this that others have

  • Automatic shutting down of ipod touch 5Gen

    Just now i checked my ipod touch and suddenly i cannot open it. Possibility it was automatically shoutdown. Don't know what to do. Please help me.

  • How to start TOOLSProcessManager  in linux R12

    Hi, We are using Oracle Apps R12 windows and Linux. i have start in windows OracleSIT_sitartha_TOOLSProcessManager from services.msc but how to start in linux ? i have check in linux [applmgr@r12 ~]$ /ora/oracle/VIS/apps/tech_st/10.1.2/opmn/bin/opmnc

  • Upgrading to EHP1

    Hi, We are upgrading from SNC 7.0 to SNC 7.0 EHP 1. Can someone please help explain how to determine this: List of which business functions which will need to be activated in the landscape (I refer here to Business Switch Framework    (SWF5)). Can so

  • Safari crashing shortly after opening.

    Hi.  Safari is crashing in just a minute or so after I open it.  Any suggestions as to how I can fix this? Thank you! Debbie Process:         WebProcess [543] Path:            /System/Library/PrivateFrameworks/WebKit2.framework/WebProcess.app/Content