Reading servlet output in Flex

Hi,
I am uploading a file to the server by using
"FileReference.upload(URLRequest)" method. URLRequest is the
servlet which reads the file content and sends that as response.
So, how to read that response back in Flex?
Help is really appreciated.
Thanks in Advance.

Hey Send response using XML format. Try to use HTTPRequest,
later read the response using, httpReq.lastresult .

Similar Messages

  • Read Servlet output stream

    how can i read servlet output stream

    i m using SAX to create an XML.
    I set result to "Servlet Output Stream" as shown below :->
    SAXTransformerFactory saxTF = SAXTransformerFactory.newInstance();
    TransformerHandler th = saxTF.newTransformerHandler();
    Transformer t = th.getTransformer();
    StreamResult stRes = new StreamResult(res.getOutputStream());
    th.setResult(stRes);
    th.startDocument();
    what i want to wright the same xml result in file at the same time(parallel y).

  • Servlet output not displayed properly in Internet Explorer

    Hi All,
    I'm developing a servlet which uploads a file. After the servlet parses the request body, it stores the file contents as a binary string in the database. While displaying the contents of the attached file, the IE(Internet Explorer) is ignoring all the newlines and spaces. IThe same uploaded file when viewed through Firefox browser is being displayed properly. I've added some debug statements to print the filecontent before sending it to servlet output stream. They look exactly as they were in the uploaded file. The MIME type is application/octet-stream.
    I've also made the response to accept "ISO-8859-1" and "UTF-8" charsets, yet the IE is not rendering the file contents properly. The code looks like this,
    response.setContentType("text/html; charset= ISO-8859-1, UTF-8");
    byte[] buff = attachment.getAttachObject();
    OutputStream out = response.getOutputStream();
    out.write(buff);
    out.close();
    I've tried using PrintWriter also. I've tried changing the content types, character encodings of request and response objects, still couldn't resolve the issue. What really baffles me is that when it's displaying properly in Firefox, why can't it render properly in IE? I'm using Win XP SP2, and IE version is 6.0.29. The content which is being sent to the output stream contains newline and space characters, but they are not displayed in the browser. Did any one face this sort of issue? Your help is highly appreciated.
    Thanks,
    Tarun.

    Hi,
    Thanks for looking into the issue. Let me tell you that I've tried keeping various content-types like text/plain, text/xml etc, but in none of those cases the IE rendered the output properly. But with the same content-type i.e text/html or text/plain, Firefox is able to render the file content properly. I've tried a brutal force approach like below,
    response.setContentType("text/plain");
    PrintWriter out = response.getWriter();
    String str = new String(attachment.getAttachObject());
    char[] buff = str.toCharArray();
    for(i=0;i< buff.length; i++)
    int n = (int)buff;
    if(n == 10)
    out.println();
    else
    out.print(buff[i]);
    out.close();
    I was trying to print a newline whenever I find a newline character in the file content. Even this didn't work. Please suggest me some way to get rid of this problem.

  • Reading the output from a object running in the local machine.

    Reading the output from a object running in the local machine.
    By using a signed applet i am lunching a small application that returns an image object, how to read that without storing it in the hard disk.
    Which means i need to read the image object return by the local application using applet or jsp .
    i am using tomacat and an html page with an applet with it to lunch the application.

    You can write that image in a binary format using OutputStream for System.out and then read it in your applet.

  • Converting servlets output to PDF fle

    How to convert Java Servlets output html file to PDF file or a Word document.

    not sure what u mean by 'convert' the output to PDF or word document
    Do you mean you want to force the browser to open file using MSWord / PDF viewer? If yes :
    For showing output as a word document, you can set the servlet response MIME type to 'application/ms-word' and set its extension to .rtf . You can then use a RTF template to build servlet output (since RTF is flat file format). By replacing placeholder tags in RTF template, you can generate content.
    For showing output as PDF, you'll need some library for PDF writing.
    hth,
    Subodh

  • Reading the output values after each step executes in LabVIEW User Interface

    Hello all,
    Development environment: TestStand 2010 SP1 and LabVIEW 2010 SP1
    Problem: is there a way to execute the subsequent steps programatically and get the output values from each of them?
    I have already extended a little bit a Full OI interface for TestStand to load up any sequence, choose some of the steps and run them step by step (something like option to Run Selected steps). What I am trying to do is to add some actions between each step and do that in User Interface (I can't modify the sequence!), so I am starting the NewExecution with some previously configured InteractiveArgsParam and set an option breakAtFirstStep to True. Afterwards I am just doing something like Step Over when debugging the sequence and this works good, but I didn't fine a way yet to read the output values from the steps...
    Then, if I wait until the execution finishes I can read my Results by processing the ResultObject, but this works only after finalizing of the test sequence. Since I wanted to stop after each step, read the values, do some actions and continue to the next step I tried to register an event callback for Trace of Execution View Manager. I can see that after each executed step this event is triggered, but when I try to read a ResultObject returned in Event Data it is not filled with values (ResultList seems to be empty?). Is it a proper behaviour or maybe I am doing the readout in wrong way? (It is the same VI as for reading ResultObjects after sequence finishes and there it works fine for arrays, containers and other data types).
    Like I mentioned I can't modify the Test sequences, I can't add a UImessages.
    What are my options? Should the trace event returns all output values from each steps or is it just used for status checking? Or maybe there is completely different approach to that matter?
    Thanks in advance for any suggestions,
    Best Regards.
    CLA, CTD, CLED @ Test & Measurements Solutions Poland
    Solved!
    Go to Solution.

    Thanks for your replay, I have tried to build it in my LabView Block Diagramm, es seems like this image.
    But the variable GetNumSubProperties ist always 0. Why?
    PS: I need only the variable "Step.Result.PassFail" from the last step, do you know, how can I get it? I think, it is maybe easier than read all the "Result".
    Attachments:
    ReadStepResultInLabview.JPG ‏39 KB

  • Read the output of the iseries CL Program from Java

    I have a Java program running on the iseries(AS400). I need to call a CL program from this JAVA.I have to pass 7 arguments to it.Out of 7, three are input parameters to CL and other 4 are its output parameters to the calling JAVA program. I am using Runtime.getRuntime().exec(arguments) to call the CL. Please suggest me how to read the output from the CL in the JAVA program.

    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    Kidding:
    If a method has at least 7 parameters, chances are one or two have been forgotten.

  • How to execute some code in command line, and read its output?

    I'v found here http://www.sap-advisor.com/abap-coding/how-to-execute-operating-system-commands-from-within-sap/ that I can execute commands from the windows command line for example inside SAP.
    But I want to take it one step further and read its output. is it possible?

    Hi RagnaRock,
    one possible approach can be outputting the results of the command into a text file (i.e. "command >result.txt"), and then read this file from SAP/ABAP.
    I hope this helps. Kind regards,
    Alvaro

  • How to  read list output into itab? - URGENT

    hai experts,
    how to read current report output for further validation i need all data which is showing in output.
    my req is,
    to read list output all data put into itab.
    reward avail for useful answer....
    regards,
    jai.m

    Hi kumar,
    you said your using second one.
    it's good. then use the below part.but check the syntax because it is there in other programs what i have already phased.
    INCLUDE <%_list>.
    DATA %_LIST TYPE SLIST_LIST_TAB ." WITH HEADER LINE.
    DATA %_LIST_WA TYPE SLIST_LISTLINE.
    DATA: BEGIN OF data_tab OCCURS 0,
    line(255),
    END OF data_tab.
    & Then use:-
    LOOP AT %_list into %_list_wa.
    data_tab-line = %_list-line.
    data_tab-line = %_list_wa-line.
    APPEND data_tab.
    Clear data_tab.
    Clear %_list_wa.
    ENDLOOP.
    kindly reward me if it's ok

  • Problems reading RefNum output parameter from ActiveX

    I'm running LabVIEW as a ActiveX server and access it from Python. Now I have encountered a problem when trying to read an output control that is a RefNum (actually a strict type def that I think is based on a DataLogRefNum containing a Enum). I get the following error message: "pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147352571), 2)"
    Has anyone experience of reading RefNums controls using ActiveX?
    From Python? C++? VB? ...?
    Thanks!
    Ola

    Hello Ola!
    Do you still have the problem?
    Cheers
    Ashwani S.
    Applications Engineer
    National Instruments Sweden

  • How to read the output from 'tlist entersq'

    Hi
    Where can I find information on interpreting the output from 'tlist entersq' ?
    We have a box that seems to go into a lock, no communication through network, nor terminal ttya.
    I did an abort on the panel and sync to force a memory dump
    I'm using scat to investigate the result.
    SolarisCAT(vmcore.0)> thread summary
            reference clock = panic_lbolt: 0x114c6f9                             
       11   threads ran since 1 second before current tick (11 user, 0 kernel)
       11   threads ran since 1 minute before current tick (11 user, 0 kernel)
       63   TS_RUN threads (50 user, 13 kernel)
        2   TS_STOPPED threads (0 user, 2 kernel)
       10   TS_FREE threads (0 user, 10 kernel)
        0   !TS_LOAD (swapped) threads
        0   threads trying to get a mutex
        0   threads trying to get an rwlock
      128   threads waiting for a condition variable (89 user, 39 kernel)
        1   threads sleeping on a semaphore (0 user, 1 kernel)
       12   threads sleeping on a user-level sobj (12 user, 0 kernel)
        7   threads sleeping on a shuttle (door) (7 user, 0 kernel)
        0   threads in biowait()
        1*  threads in entersq() (1 user, 0 kernel)
       63   threads in dispatch queues (50 user, 13 kernel)
      225   total threads in allthreads list (159 user, 66 kernel)
        0   thread_reapcnt
        5   lwp_reapcnt
      230   nthread
    SolarisCAT(vmcore.0)>  tlist entersq
      thread        pri pctcpu           idle   pid         wchan command
      0x300027dd7a0 142  0.024       1m41.83s  1684 0x300007fff18 /sz/tcp/bin/tig_tcp.bin
       1 thread in entersq() found.
    threads in entersq() by syncq:
    1 thread: 0x300027dd7a0
    syncq @ 0x300007ffee0
    sq_count: 0    sq_head: 0x30001de6e80  sq_tail: 0x30001de6e80
    sq_evhead: 0xcff010000 sq_evtail: 0x100000000cafe      sq_nqueues: 0
    sq_needexcl: 0 sq_private: 0x3000155dd18       sq_next: 0xbaddcafe
    sq_pri: 276
    sq_occount: 0
    sq_flags: 0x200 ()
    sq_type:  0x0
    sq_svcflags:  0x0
    sq_lock @ 0x300007ffee0:
      adaptive mutex:  owner: 0x0  waiters: false
    per-module syncq for ip
    streamtab @ 0x14ad6b0
    qinit     @ 0x14ad570
    modinfo   @ 0x14ad540
    queues:1 sq_msgs:1 sq_mblks:36 sq_alloc:13247273932581836904
    SolarisCAT(vmcore.0)> thread 0x30001de6e80
    ==== user thread: 0x30001de6e80 address translation failed for pid: 32 bytes @ 0x452e0d0a2a2a2a20
    pid: 0  PIL: 3 ====
    cmd:
    t_wchan: 0x30001dd5640 
    t_stk: 0x1263bfc  sp: 0x0  t_stkbase: 0x30002aa3ec0
    t_pri: 0  pctcpu: 0.000036  t_lwp: 0x30001de0d80  machpcb: 0x30001dd4c08
    t_procp: 0x30002df2900  p_as: 0x30002df2978  hat: 0x6420373031206368address translation failed for hat_3: 80 bytes @ 0x6420373031206368
      cnum: 0x0
    address translation failed for hat_3: 80 bytes @ 0x6420373031206368
      size: 4984936174853958176  rss: 0
    bound cpuid: 768  bound psrset: 768  last cpuid: 0 
    idle: -17371523 ticks (190888 days 10 hours 34 minutes 34.26 seconds)
    start: Wed Jul 10 21:34:52 6497
    age: -3297429488912 seconds (38164693 days 3 hours 48 minutes 32 seconds)
    swapped out: 3298566244800 (190888 days 4 hours 48 minutes 49.63 seconds later)
    interrupted (pinned) thread: 0x30001de6ef8
    tstate: unknown state
    tflg:   T_INTR_THREAD - thread is an interrupt thread
            T_WOULDBLOCK - for lockfs
            T_DONTBLOCK - for lockfs
            T_DONTPEND - for lockfs
            WAITCVSEM - waiting for a lwp_cv or lwp_sema on sleepq
    tpflg:  TP_CHKPT - thread is being stopped via CPR checkpoint
            TP_PRVSTOP - thread is virtually stopped via /proc
            TP_MSACCT - collect micro-state accounting information
            TP_STOPPING - thread is executing stop()
    tsched: none set
    pflag:  SLOAD - in core
            SLOCK - process cannot be swapped
            SPREXEC - process is in exec() (a flag for /proc)
            SSCONT - SIGCONT has been posted to the process
            SBPTADJ - adjust pc on breakpoint trap (/proc)
            SUGID - process was result of set[ug]id exec
            SJCTL - SIGCLD sent when children stop/continue
            SNOWAIT - children never become zombies
            SVFORK - process resulted from vfork
            SVFWAIT - parent of vfork waiting for child to exec
            EXITLWPS - have lwps exit within the process
            SWAITSIG - SIGWAITING sent when all lwps block
            HOLDFORK1 - hold lwps in place (not cloning)
            SMSACCT - process is keeping micro-state accounting
    pc: 0x30003e63600       0x30003e63600:  illegaltrap     0x00000000
    -- no stack --

    Hello ejp,
    First of all i thank you for the reply.
    I explain the process which i am doing in side the thread.
    After connecting to the remote machine, it asks another password.
    so i read the output after connecting. if it equals "password:", then write the 2nd password. then i read the output. it will be like "system>" . if this prompt comes like this, then i write the super user name and super user password. then the prompt will be like "system#". then i write the command which i need to execute and read the output whether the command is success or not.
    So after every output read, i interrupt the thread using interrupt() method. its working fine if i execute via GUI ie, click the button. But its not working when i scheduled this job in a scheduler ie, it will be executed when the time elapsed.
    Give an idea to fix this bug please.
    rgds
    tskarthikeyan

  • Reading the output from another program.

    I haven't used Java in a good long while so I need someone to point me in the right direction. I have a C program that I call from a command line (windoze boxen) and it spits out some neat data. I can call it from inside a Java program, but how do I then read the output from the calling Java program? I'd just alter the C program, but I lost the source.

    This article explains how to correctly execute another program from your
    Java program, and read its output:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Servlet Output Streams and clearing

    I am using servlets, and I want to be able to print something repeatedly. Well, that's not exactly true: I can print something repeatedly. Using a ServletOutputStream, it doesn't seem possible to clear what has already been written. Here's the code:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.io.*;
    public class AlwaysTime extends HttpServlet {
         public void doPost(HttpServletRequest req, HttpServletResponse res)                throws ServletException, IOException {
              HttpServletResponse oldRes = res;
              Date now = new Date();
              res.setContentType("text/html");
              ServletOutputStream out = res.getOutputStream();
              out.println("<html>");
              out.println("<head>");
              out.println("<title>Clock</title>");
              out.println("</head>");
              out.println("<body>");
              out.println("<h1 align=\"Center\">");
              out.println(now.toString());
              out.println("</h1>");
              out.println("</body>");
              out.println("</html>");
              try {
                 Thread.sleep(1000);
              } catch (InterruptedException ie) {}
              // Do nothing: wait for 1 second.
              doPost(req, oldRes);
         public void doGet(HttpServletRequest req, HttpServletResponse res)
              throws ServletException, IOException {
              doPost(req, res);
    }This code prints the time every second, but I want to clear the previous output stream. I thought the code shown above would work, but of course, oldRes points to the same object as res. But I don't know how to clear an output stream, so that it is completely empty. Instead, each of the new lines are appended to the same output stream.
    This doesn't only apply to servlet output streams: is there some way to clear the System output stream, for instance?
    But mainly the servlet output stream ...

    You would not want to use HTTP for this type of functionality. HTTP is known as a 'stateless' protocol that simply returns one exact response for each request. So, there is not way to 'clear' the stream (technically, you would not do so for 'normal' streams either, but when you add HTTP into the mix, the task is definitely not possible).
    You could implement the above using a RSS feed, or by using HTTP meta-refresh tags on the page itself ot resubmit the requests every second (though this would be inefficient). An applet would also do the task.
    - Saish

  • Servlet  output correct in ie and netscape, but not in portal

    I have a servlet that retrieves and xml document, applies a
    stylesheet, and uses PrintWriter to output the html.
    When I run the servlet, the output is correct in ie and netscape.
    So, I set the servlet up as a web portlet and have put it on a
    portal page.
    My problem: When I run the portal page, the mdashes and
    rsquotes, etc. show up in portal as question marks.
    I went into the provider.xml and added some information
    (contentType,charset), but that had no effect.
    Ideas appreciated.
    Thanks.

    I have been doing some research, and this appears to be some
    sort of character encoding/unicode problem.
    I have specified UTF-8 in my servlet. Does portal not work with
    UTF-8?
    Is there a setting somewhere that I can check in portal to
    verify what character encoding it is using? (ISO-8859-1, US-
    ASCII, etc?)
    This is a sample of my servlet code:
    public void DoGet(HttpServletRequest request, HttpServlet
    Response,response)
    throws ServletException, IOException
    DOMParser parser;
    XMLDocument xml,xsldoc;
    URL xslURL,xmlURL;
    String xmld = "";
    String xsld = "";
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try
    parser = new DOMParser();
    parser.setPreserveWhitespace(true);
    xslURL = createURL(xsld);
    parser.parse(xslURL);
    xsldoc = parser.getDocument();
    xmlURL = createURL(xmld);
    parser.parse(xmlURL);
    xml = parser.getDocument();
    XSLStylesheet xsl = new XSLStylesheet(xsldoc,xslURL);
    XSLProcessor processor = new XSLProcessor();
    processor.processXSL(xsl,xml,out);
    Any advice appreciated.

  • ### URGENT: duplicated servlet output ###

    Hi,
    I'm usin cos.jar of servlets.com for file uploading. But, sometimes, the output of my servlets are duplicated. This problem doesn't occur everytime even if for the same uploaded files. Also, When I encounter this problem on my desktop, It runs on the other desktops without any problem.
    I'm sure that lines of uploaded files are not re-read/re-processed twice immediately. Because, may applications would return errors in that case. But, if entire file is re-read/re-processed, there would not be errors returned.
    Here are my configuration:
    Browser:Internet Explorer 5.0
    OS: Windows 2000 Professional
    Servlet Engine: Resin 2.1.9
    Please help...This is very important problem. Because, the output of our sevlets are duplicated.
    thanks in advance...

    Thanks for the reply.
    I'm sure this is not a thread synchronization problem.
    Here is the doPost():
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    itrprofThread iThread;
    iThread = new itrprofThread(request,response);
    iThread.start();
    try {
    iThread.join();
    } catch (InterruptedException e) {}
    I'm sure that uploaded file is processed twice after the first entire process of the file is finished. Here is the proof:
    CORRUPTED LINEs AND THEIR DEPENDENTs (2 of 2)
    Errror code Line number Line
    itp-05 [2] 99 WAIT #0: nam='SQL*Net message from client' ela= 98956 p1=1413697536 p2=1
    itp-05 [2] 353 WAIT #0: nam='SQL*Net message from client' ela= 98956 p1=1413697536 p2=1
    As you see above, the lines are the same lines. In fact, it's single line in the uploaded file. But, If you notice the line numbers of the lines, they are different. The first line number is correct. But, the second is wrong. Because, second line is duplicated.
    Also, There are 252 lines in the file. But, line number of the second line is reported 353. This is not possible.
    I'm now sure that uploaded file in the second phase is processed after the first phase is completed. Because:
    Line number in the first phase: 99
    Total line number in the file: 252
    Line number in the second phase: 353
    If I sum 99 and 252, it gives 351. It's proof the entire file is processed twice after the first phase is completed.
    is is possible to see the contents of HTML form data before sending to servlet ?
    PLEASE HELP, THIS IS VERY IMPORTANT PROBLEM.

Maybe you are looking for

  • My iTunes won't start up and i cant fix it HELP!!!!!!!!

    Ok when ever i try to open up iTunes a message box appears and says "The folder "iTunes" cannot be found or created, and i required. The default location for this folder is inside the "My Music" folder." so that is what shows up, it was working last

  • 3GPs from 6280 won't play in Multimedia player

    I've recorded a number of 3GP videos on my 6280 but I can't play them back on my PC. It seems that the software (PC Suite) doesn't seem to like it when i record with a video resolution greater than 174*144. Anyone else notice this?

  • Database Configuration Assistant in Red Hat 7.1

    Hi, I'm trying to install 9i database in Red Hat 7.1 The instalation of the source files works fine. Now i'm trying to create the database with "Database Configuration Assistant - DCA". After all parameters are set, the DCA trys to create the databas

  • Problem in update with DB Adapter

    Hi, I have a Table with one attribute(Primary key). I want to update that table by replacing the existing value(Overriding). Developed one BPEL process by configuring db adapter with operation as insert or update and I checked by executing the BPEL p

  • Certain contact on skype cannot send me messages n...

    For a few days now, I cannot read messages a contact says to me on the outlook.com website and they don't receive mine. When I got onto my phone skype, their messages went through and I tried sending them a message through the website with my phone s