Preventing hang on a method call in doGet ()

Hi,
I have the following problem.
Inside the doGet() method, I have a method call X which may take a long time or hand, what it does is do some calculations and return a object Obj. Then I can send this Obj back to client.
My question is how can i set a Timeout, say 20 seconds. If the method can be finished within 20 sec, then I just let it keep going. It X takes more than 20 seconds, before X finish (or maybe it never finish) I will set a error message into Obj then sent it back to client.
Can anybody help me with some sample code or suggestion?
Any input will be appreciated.

Thanks, @Sujoy.
According to your suggestion, each expensive method will take AT LEAST the specified wait miliseconds to finish.
My solution was to start a timer thread before call the method, after the X number of miliseconds, the thread will check the return object from the method. but the problem is the thread has no way to access to the local varialbe inside the method. If you make the variable outside the doGet, which is an instance variable, every request thread will be capable of changing it, which is not acceptable.
Any better idea? thanks!

Similar Messages

  • DoPost() and doGet() method calling

    Hi All,
    What is the purpose of calling the doGet() method inside of doPost() instead of calling it directly.
              doPost(HttpServletRequest request, HttpServletResponse response){
                                    doGet(request,response);
                why we are calling the doGet() method like thisThanks in Advance,
    mahes

    Seemingly the post and the get do exactly the same thing, so to avoid duplicate code, (s)he just simply had one call the other.
    However, you shouldn't really do it this way. You should break out the parts of the methods that are the same into new methods, and call these new methods from both the post and get methods. That will allow the two methods to handle some other things slightly differently. I.E. the get method is not suppossed to cause side effects (i.e. you are not suppossed to change any data when using a get method) whereas post methods can.

  • 11gR2 error: call a bounded task flow with method call as default activity

    hi all,
    We migrated several applications to the JDev 11g R2.
    There are 2 applications that contain a bounded task flow where we define Method Call as default activity.
    We need invoke specific actions before opening the page.
    They run well with 11gR1.
    But with *11G R2*, I can’t call directly this task flow with the following URL:
    http://127.0.0.1:7101/MyAPP/faces/adf.task-flow?adf.tfId=my-flow-def&adf.tfDoc=/WEB-INF/flows/my-flow-def.xml
    Message:
    *<SecurityUtils><invokeURLAllowed> ADFc : impossible to call directly the task flow '/WEB-INF/flows/ my-flow-def.xml #my-flow-def' with the help of URL*
    (original message: <SecurityUtils><invokeURLAllowed> ADFc : impossible d'appeler directement le flux de tâches '/WEB-INF/flows/ my-flow-def.xml #my-flow-def' à l'aide de l'URL.)
    Any idea?
    Thanks for you help

    Hi,
    Have a look at the task flow properties, in PatchSet1, a new feature "invokeURLAllowed" is added that prevents bounded task flows from being URL accessible for security reasons. You can swithc this feature on and off
    Frank
    Ps.: I though that bounded task flows that you call from a URL generally needed to have a viewActivity as the default activity

  • How to call actionLister after "enforcePreventUserInput" method called

    Hi,
    in my use case i have a table with inputText where i have valueChage Listener method execute and one commadImageLink button(save).
    so i have add glass pane to prevent user input until value chage event is busy. using this tutorial link.
    http://www.oracle.com/technetwork/testcontent/27-long-running-queries-169166.pdf
    and this is working fine.
    problem is when user change some value on input Text and click on save button.
    javascript method call and glass pane popup visible to user until value change event is not completed accepted. but it is skip save button action Listener method.
    i mean actionListener method of save button not executed.
    i want after executing value chage event busy state popup save method is also executed.
    How can i do this?
    regards
    Manish

    Click on the Save button after the valueChangeEvent call has returned implying after the glass pane popup closes. Won't be feasible to invoke two action listeners simultaneously unless Ajax is used for the JavaScript method call from the inputText action method to return.
    Similar to
    <h:inputText id="name" event="" value="#{}">
       <f:ajax listener="#{}" render="" />
    </h:inputText>

  • Printing from methods other than doGet()

    Hi,
    I want to send back a "result" string to the client side browser. Now, the problem is that it should be sent back from a method different from doGet(). Iam doing something like this................
    public class A extends HttpServlet
    PrintWriter out;
    public void doGet() throws......................
    out = response.getWriter();
    public void someOtherMethod()
    out.println(result);
    The call in someOtherMethod() is not working. What should be done for this ?
    Thank you.

    Hi,
    Thank you for the reply. I have tried it. The problem is Iam using a Timer class. Have a look at the code Iam using.......
    public class event extends HttpServlet
    private Timer t;
    private static int count = 1;
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException
    String eve;
    String res;
    eve=request.getParameter("opt");
    EventAgent de=new EventAgent();
    res=de.sendEventToEventAgent(eve);
    PrintWriter out = response.getWriter();
    out.println(res);
    t = new Timer();
    t.schedule(new GenerateRegNo(request,response),2,12000);
    class GenerateRegNo extends TimerTask
    private Random r;
    private int no;
    private String result;
    private PrintWriter out;
    public GenerateRegNo(HttpServletRequest req,HttpServletResponse
    res) throws IOException
    r = new Random();
    out = res.getWriter();
    public void run()
    if(count <= 20)
    DispReg();
    count++;
    else
    t.cancel();
    public void DispReg()
    no = r.nextInt(3);
    if(no == 0)
    no = no + 11;
    else
    no = no + 10;
    EventAgent de=new EventAgent();
    result=de.sendEventToEventAgent(String.valueOf(no));
    out.println(result);
    Still not getting the desired result..........
    Thank you once again.

  • Rmi method call timeout

    i was wondering if there was any way to timeout a rmi method call.
    the situation i had was that a client would envoke an rmi method, and
    the method would deadlock in weblogic. the client making the call will
    hang forever.
    thanks

    Thank you for this enlightening addition. I regret I failed to perceive
    earlier that your comments were to be interpreted as evidence of sincere
    commitment to solving this problem.
    Regarding 7.0, you'll note that I described the timeout attribute solution
    as "improving stability" rather than as a complete cure. It should be borne
    bear in mind that this is an alternative to a completely locked system. When
    stress tested, this change did allow the application to recover and run for
    the rest of the day.
    I'm obliged to you for your concern regarding any liability I might be
    incurring in relation to the BEA licensing agreement. Fortunately I think I
    may be able to put your mind at rest on this matter relatively easily. If I
    may direct your attention to the BEA support site, my experience is that on
    entering the search terms "rmi descriptor timeout", the relevant information
    will be revealed. Also, I suspect that, as a fellow engineer, it has not
    escaped your attention that the RMI descriptor is a valid XML document. As
    such, it has a DTD named "rmi.dtd" which (alas) also fails to conceal this
    attribute.
    While we're pursuing what has now become a gratifyingly productive vein,
    let's offer another possible approach to this issue, namely the use of
    per-VM timeouts for socket calls. These were introduced in the Sun JDK 1.4.1
    and so are available to people running WebLogic 8.1 today. Again these
    suggestions have been tested for basic socket I/O (I haven't tried RMI). To
    my knowledge these are not endorsed by BEA:
    For client connections, timeouts can be set globally by passing the
    following startup parameters to the JVM:
    sun.net.client.defaultConnectTimeout (default: -1)
    sun.net.client.defaultReadTimeout (default: -1)
    sun.net.client.defaultConnectTimeout specifies the timeout (in milliseconds)
    to establish the connection to the host.
    sun.net.client.defaultReadTimeout specifies the timeout (in milliseconds)
    when reading from input stream when a connection is established to a
    resource.
    (reference: Sun's Networking Properties documentation at
    http://java.sun.com/j2se/1.4.1/docs/guide/net/properties.html )
    Supplying non-default values for these properties should allow a server to
    recover from a blocked downstream system if socket I/O is being used.
    Regards
    Alex
    On Fri, 30 Jan 2004 09:02:23 -0800, Andy Piper <[email protected]>
    wrote:
    Alex Thomas <[email protected]> writes:
    Hardly a constructive response to what is clearly a significant problem.
    First, it should be obvious that this issue will be encountered in any
    distributed system using T3 or RMI, not because of any shortcoming in
    WebLogic services but because of blocking behaviour in downstream systems.That's why it is a new feature in 9.0. I'm not arguing that the
    use-case is invalid, simply that your suggestion should not be tried.
    Second, the solution I proposed has been tested (on 7.0SP1) and does improve
    overall stability, as other people here have apparently discovered.Tested by who? Not by us because we know there are significant,
    dangerous, problems with the approach you describe. Support are
    under strict instructions not to offer this as a solution to
    anyone. If anyone in BEA told you, they shouldn't have. If you
    discovered it by decompiling the code then you are in violation of
    your license agreement.
    There is a supported mechanism for timing out connect attempts in 7.0
    and later which you can get through support, but for timing out RMI
    calls you will have to wait until 9.0 (or cook up a business case for
    a backport).
    Hope this clears things up.
    andy

  • Taskflow Method call receiving null parameter.

    Hi all,
    I am using 11.1.1.6. I have created in my application an extra project which is pure Java objects and exposed a master class as a POJO DC. In my application, I have a taskflow where I have dragged and dropped one method from my POJO DC - 2 of the parameters of this methods are coming from an application scope bean. I have debugged the application, and made sure that the object being returned by the getter of my app scope bean is not null. So basically, when the breakpoint is in the return statement of my getter the oject is not null and it has been correctly initialized. Just after that, the next breakpoint is in the class receiving the parameter in my POJO DC class. In there, the object is NULL.
    Does anyone knows wat could be the reason??

    Hi Frank Nimphius-Oracle,
    That is precisely the problem.  The object is being passed as to the taskflow as an input parameter (getting it from my application scope bean). If I access the pageFlowScope inside my taskflow I see it and its there, correctely intialized. However, when I call a method call activity that consumes that object as parameter, all what it gets is null.
    The method that consumes this object is in a separate project, and its exposed in a POJO DC. I don't know if it has to be with the complexity of the object I am passing or what but I don't understand why its not being passed correctly to the DC Method.

  • Closing an anonymous stream in method call

    Will an anonymous stream in a method call be closed in the same manner an anonymous stream that is created in an object instantiation will be?
    I know this will close the anonymous FileInputStream:
    DataInputStream in =
    new DataInputStream(new FileInputStream("filename.txt"));
    /* ... code ... */
    in.close();But will this?
    MyPropertiesClass myPropertiesClass = new MyPropertiesClass();
    myPropertiesClass.store(new FileOutputStream("file.txt"));MyPropertiesClass extends Properties, and uses its store().
    I know the JavaDoc for Properties says:
    "After the entries have been written, the output stream is flushed. The output stream remains open after this method returns."
    My question is will the FileOutputStream("file.txt") be closed and garbage collected eventually after this method call because I don't have a reference to it? myPropertiesClass sticks around for a long time afterwards, will the FileOutputStream as well?
    Thanks for any insight,
    KJ

    My question is will the FileOutputStream("file.txt") be closed and garbage collected eventually after this method call because I don't have a reference to it? > myPropertiesClass sticks around for a long time afterwards, will the FileOutputStream as well?Your only hope would be if FileOutputStream overrode finalize and closed the stream there -- but it doesn't (check the API -- finalize isn't overridden). I doubt if Properties retains a reference to the OutputStream you pass to store -- why would it need to? In any case, the bottom line is that output stream isn't being closed until your process exits.
    Why not bite the bullet and rewrite that line of code so that you can explicitly close the stream?
    OutputStream out = new FileOutputStream("file.txt");
    try {
        myPropertiesClass.store(out);
    } finally {
        out.close();
    }It's not one line, but who cares? You could wrap it up in a short utility method:
    static void storeProperties(Properties properties, String path) {...}

  • Using a dynamic variable in the Import command of a Method call

    Hi,
    I am trying to make a Method call fully dynamic.
    I have found out how to make the Method name dynamic, but I am having trouble figuring out how to make the Importing statement dynamic.
    in my code below:
          CALL METHOD o_main->(v_call)
            IMPORTING
              it_ekko = i_ekko.
    I would like to know if it's possible to make both "it_ekko" AND "i_ekko" dynamic so I can use this same call for various tables.
    Hope that makes sense...thanks for your help.
    Andy

    Hi Andrew,
    The method call is fully dynamic; not only the parameters can be specified dynamically but also the method name.
    This is a help extract:
    DATA: line     TYPE c LENGTH 80,
          text_tab LIKE STANDARD TABLE OF line,
          filename TYPE string,
          filetype TYPE c LENGTH 10,
          fleng    TYPE i.
    DATA: meth  TYPE string,
          class TYPE string,
          ptab TYPE abap_parmbind_tab,
          ptab_line TYPE abap_parmbind,
          etab TYPE abap_excpbind_tab,
          etab_line TYPE abap_excpbind.
    DATA: exc_ref TYPE REF TO cx_sy_dyn_call_error,
          exc_text TYPE string.
    class    = 'CL_GUI_FRONTEND_SERVICES'.
    meth     = 'GUI_DOWNLOAD'.
    filename = 'c:\temp\text.txt'.
    filetype = 'ASC'.
    ptab_line-name = 'FILENAME'.
    ptab_line-kind = cl_abap_objectdescr=>exporting.
    GET REFERENCE OF filename INTO ptab_line-value.
    INSERT ptab_line INTO TABLE ptab.
    ptab_line-name = 'FILETYPE'.
    ptab_line-kind = cl_abap_objectdescr=>exporting.
    GET REFERENCE OF filetype INTO ptab_line-value.
    INSERT ptab_line INTO TABLE ptab.
    ptab_line-name = 'DATA_TAB'.
    ptab_line-kind = cl_abap_objectdescr=>changing.
    GET REFERENCE OF text_tab INTO ptab_line-value.
    INSERT ptab_line INTO TABLE ptab.
    ptab_line-name = 'FILELENGTH'.
    ptab_line-kind = cl_abap_objectdescr=>importing.
    GET REFERENCE OF fleng INTO ptab_line-value.
    INSERT ptab_line INTO TABLE ptab.
    etab_line-name = 'OTHERS'.
    etab_line-value = 4.
    INSERT etab_line INTO TABLE etab.
    TRY.
        CALL METHOD (class)=>(meth)
          PARAMETER-TABLE
            ptab
          EXCEPTION-TABLE
            etab.
        CASE sy-subrc.
          WHEN 1.
        ENDCASE.
      CATCH cx_sy_dyn_call_error INTO exc_ref.
        exc_text = exc_ref->get_text( ).
        MESSAGE exc_text TYPE 'I'.
    ENDTRY.
    BR,
    Valentin

  • Error on /SafeMode: error while trying to run project uncaught exception thrown by method called

    i try run VS 2012 with /SafeMode. I create new empty Winform. When I start debug, I got:
    "error while trying to run project uncaught exception thrown by method called through reflection"

    Hi Matanya Zac,
    Did you restart your machine? How about installing the VS2012 update 4?
    >>error while trying to run project uncaught exception thrown by method
    Did you install the VS update in your VS IDE? I met this issue before which was related to the VS update:
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/5ead8ee9-ea09-4060-88b0-ee2e2044ff82/error-while-trying-to-run-a-project-uncaught-exception-thrown-by-method-called-through-reflection?forum=vsdebug
    If still no help, I suggest you repair your VS, and then restart your machine, test the result.
    Best Regards,
    Jack
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • AcquireConnection method call to the connection manager Excel connection Manager failed

    I used VS Studio 2008 (BIDS version 10.50.2500.0) on an WinXp machine (v 5.1.2600 SP3 Build 2600) to create a package that writes multiple query results to different tabbed sheets of a single excel spreadsheet. The package was working just fine and has run
    successfully multiple times, but all of a sudden when opening the project, every single Data Flow task with an Excel Connection Manager displayed error icons. Each raises the following error message when attempting to open the Advanced Editor:
    SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005 Description: "Unspecified error". Error at DataFlow task name: SSIS error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method
    call to the connection manager Excel connection Manager failed with error code 0xC0202009. There may be error messages posted before this with more information on why the Acquire Connection method call failed. Exception from HRESULT: 0Xc020801c (Microsoft.SQlServer.DTSPipelineWrap)
    From the time I created the original package (when it worked fine) until now:
     1) I have been using the same computer, the same login account and the same permissions.
     2) I have been writing to the same (32 bit) 2010 Excel file (which I created) in a folder on my local machine.
     3) The filename and location have not changed; a template file is used each time to move and overwrite the previous file. Both are in the same locations.
     4) I can independently open the target Excel file and the template Excel files with no errors.
     6) The ConnectionString has not changed. The Connnection String I am using is
      Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Conversion\Conversion\Results_dt01.xlsx;Extended Properties="EXCEL 12.0 XML;HDR=YES;".
     7) Run64BitRuntime is set to False.
    8)  Delay Validation is set to true
    9) This is not running under a SQL job  
    10) There are no child packages being run
    I CAN create a NEW Excel Connection Manager, assigning it the exact same target Excel spreadsheet, successfully, but when I attempt to assign it to the Data Flow destination this error occurs:
    "Test connection failed because of an error in initializing provider. Unspecified error."
    Thinking that the driver might be corrupt, I opened a second SSIS package, which also uses the Excel Connection Manager (same driver) and this package continues to work fine on the same workstation with no errors.
    I have searched online for causes of this error for many hours and found nothing that helps me to solve this issue.
    Does anyone have any suggestions for me?

    Yes, I have verified that the Excel file is not in use or opened by anyone, including me. It has been two months since I opened this particular package, although I have been working with other packages in this project. I just discovered that another
    package in the same project has the same problem - all Data Flows that output to an Excel Destination now have the same error icons. This second packages outputs to an entirely different Excel file than in the first package.  A summay:
    Package #1 has error on every Excel Destination and uses templateA to overwrite fileA and then writes to fileA
    Package #2 has error on every Excel Desintation and uses templateB to overwrite fileB and then writes to fileB
    Package #3 has no error on any Excel Destination and is linked to multiple files (none are A or B)
    Package #1 and #2 are in the same project, but Package #3 is in a separate project .
    I will try replacing the Excel files with new ones for Package 1 and 2.

  • [Load data from excel file [1]] Error: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "Excel Connection Manager" failed with error code 0xC0202009. There may be error messa

    Error
    [Load data from excel file [1]] Error: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.  The AcquireConnection method call to the connection manager "Excel Connection Manager" failed with error code 0xC0202009.  There
    may be error message
    I am using BIDS Microsoft Visual Studio 2008 and running the package to load the data from excel .
    My machine has 32 bit excel hence have set property to RUN64BITRUNTIME AS FALSE.
    But the error still occurs .
    I checked on Google and  many have used Delay validation property at Data flow task level to true but even using it at both excel connection manager and DFT level it doesnt work
    Mudassar

    Thats my connection string
    Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\SrcData\Feeds\Utilization.xlsx;Extended Properties="Excel 12.0;HDR=NO";
    Excel 2010 installed and its 32 bit edition
    Are you referring to install this component -AccessDatabaseEngine_x64.exe?
    http://www.microsoft.com/en-us/download/details.aspx?id=13255
    Mudassar
    You can try an OLEDB provider in that case
    see
    http://dataintegrity.wordpress.com/2009/10/16/xlsx/
    you might need to download and install ms access redistributable
    http://www.microsoft.com/en-in/download/details.aspx?id=13255
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • What are the methods called while navigating from one applet to another one

    Hi All,
    Could any one brief me about "When you navigate from one applet to another what are the methods called ?".
    Thanks in advance.
    Best Regards,
    N.Madhusudhanan.

    http://forum.java.sun.com/thread.jsp?forum=421&thread=426771&tstart=0&trange=100

  • Issue with a method call in a TaskFlow (works 2 times instead of 1)

    Hi guys,
    i'm using jdev11.1.1.1.2.0 and the integrated weblo or remote weblo 10.3.2.0.
    I'm encountering a problem with a method call which is invoked inside a Task Flow.
    Let me tell us the details of :
    I'm invoking a method call which is part of a Task Flow from the backingbean of the view which is placed before the method call in the taskFlow diagram.
    AN outcome String from the method of the backing bean allows to navigate to the method of the Task flow.
    The method call is called and works normally BUT MY PROBLEM IS THAT THE METHOD IS CALLED TWO TIMES SO THE RESULT IS FALSE.
    For information, the second time the method is called it takes care of the result when it is invoked the first time. So its parameters are updated and are a little different from the first time to the second time.
    NB : This method consists of inserting a row in the database. My result is 2 rows inserted instead of one.
    Thanks for help for this strange behaviour

    Hi
    create a temp calculated column
    =IF(ISBLANK([Duration]),"",[Item Start Date]+([Duration])
    and check if it's working OK
    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

  • When I am on a call in my car I can play and hear the music on my iPhone but when I hang up from the call the music reverts back to my iPhone speaker.

    when I am on a phone call in my car I can play and hear my iPhone music thru the car speakers but when I hang up from the call, the sound reverts to my iPhone speaker and longer plays thru the car speaker.

    Hello, Jordanali. 
    Thank you for visiting Apple Support Communities. 
    I understand that your car will not resume playing music after accepting a call.  Here is a troubleshooting article that I would recommend going through when experiencing this issue.   
    Get help using your iPhone, iPad, or iPod touch with your car stereo
    http://support.apple.com/en-us/HT203412
    Cheers,
    Jason H.

Maybe you are looking for

  • HT4528 how can i download free apps without a credit card?

    Hello. I just received a new iphone and want to try out some of the free apps on the app-store.  i'm used to being able to download free apps w/o itunes within the Droid enviroment.  This seems complicated with having to install itunes, and having to

  • JDev 9i or 10g for a new project??

    Hi, I plan to use Linux, BC4J, Struts and JSP (or ADF) in a new project which should be productive in June 2004. I'm really uncertain which version to use. I think 904 is a stable release, but lacks the easy web development of ADF. But is 10g is not

  • How can I set my time capsule to back-up only once a day?

    How can I set my time capsule to only back-up once a day.  It appears to be backing up several times a day.  Not sure there is a set schedule for the back-ups and they take a great deal of time; over an hour each.

  • Any way to connect ipod touch 3G to other non apple devices via Bluetooth??

    Hey People, I was jus wondering , can i connect ipod touch 3G to other non apple devices via Bluetooth?? is there any special application which fullfill my wish, if it is there, then it will make my day,,,,,,,,,,,,,,,

  • Function Area derive from cost center

    Hi, here is a question. The function area was input in the cost center master data. Cost center A ( Function area 1000), Cost center B (Function area 2000) Then creat a PO with Account Assignment Category(K), Item Category (B), input the cost center