Forums Register Login

jsp/servlet executes business method

+Pie Number of slices to send: Send
Hello guys,

I have few JSP/Servlet's. Also, I have class with business methods, and my JSP/Servlets are invoking these business methods. These business methods could make calls to EJB, or access databases via JDBC, etc., etc., etc.

What is the easiest and proper way to make sure, that after invoking such business method our JSP/Servlet will wait for N seconds, and if method will not finish it's execution, so JSP/Servlet will just kill it?

How should I call my business methods from JSP/Servlets?
Also, the system will have pretty a lot of users, so I need to be sure that nothing will be corrupted/crashed because of the implementation of this task.

Thanks.
+Pie Number of slices to send: Send
 


What is the easiest and proper way to make sure, that after invoking such business method our JSP/Servlet will wait for N seconds, and if method will not finish it's execution, so JSP/Servlet will just kill it?


Servlets and JSPs don't time out and writing something to make them do so, would be tricky at best.
What I do for long running processes is kick off the process and then immediately return the user to a status page that refreshes every n seconds. When the page refreshes it checks a status field. Once the status field is 'COMPLETE' I then redirect or forward the user to the content generated by the process.



How should I call my business methods from JSP/Servlets?
Also, the system will have pretty a lot of users, so I need to be sure that nothing will be corrupted/crashed because of the implementation of this task.
Thanks.


Assuming your JSPs, Servlets, and external processes are thread-safe, it just comes down to load testing and profiling to insure that your product is sufficiently scalable for it's intended purpose. A subject that is way beyond the scope of a forum post.

Let us know if you're not sure about thread-safety in a servlet app.
+Pie Number of slices to send: Send
Thank you for your response.

May be I wasn't clear in my question. I'll try to clarify below.

For example, my JSP looks like



and MyLib class has method helloWorld() which returns String.
This method executes method in some EJBs, which is doing many-many things, and that takes time. At the end, helloWorld() gets some return from EJB's method, mix it with something else, and creates String and returns it.
So, JSP successfully output it.

My goal is to do the following.
From class MyLib, from it's method helloWorld() I need to execute EJB's method. But If it will not finish it's work in 3 seconds (just for example!) - I still wish that method helloWorld() will return String "Sorry, EJB method failure!".

This way, in any case, JSP in max 3 seconds will do some output.
This is exactly what I need.



Thank you for your help.
[ February 13, 2005: Message edited by: Olexiy Prokhorenko ]
+Pie Number of slices to send: Send
I understood the first question.
My answer is that I don't think what you're trying to do is a good idea.

What if the process succeeds but after 3.5 seconds?
+Pie Number of slices to send: Send
I understand all possible limitations and minuses of such solution.
But in our application it's okay to follow them.

As a matter a fact, we can forecast that method will finish it's processing in 3 seconds (for example). This way, we will force MyLib to "kill" any non-finished method in 6 sec.
But we will know for sure that we will get response max. in 6 seconds.

This is what for I need such functionality.
+Pie Number of slices to send: Send
Hmm. The pattern I suggested can handle that.
I, personally, don't know of a clean way to impose a time limit on a request.

Maybe someone else does.
Good-Luck
-Ben
+Pie Number of slices to send: Send
I was about to move this to the threads forum, but I see you cross-posted there already.

Please don't do that, it creates duplicate conversations and wastes the time of the people trying to help you, like you just did to Ben. This thread is closed.
And then the flying monkeys attacked. My only defense was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


Reply locked
This thread has been viewed 1052 times.
Similar Threads
EntityManager on Sequence Diagram
Automate login..... HELP
MySQL query to fill HTML combo box?
jsp/servlet executes business method
Is this MVC?
Calling forms from within a servlet and returning that information to a database
Dynamically populating drop down menu with database values
shine J2EE service oriented framework
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 08:40:32.