• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

stop executing of a servlet by another servlet

 
ketaki gujarathi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

Is there a way in which I can stop the executing of a function in servlet by settling some attribute in session using another servlet.
For eg:
In jsp < %session.setAttribute('cancel',"") %> On submit button I am calling a servlet which has following code
servlet1 -->(String str = session.getAttribute(cancel) ){ if (str.equals(somevalue) break;}

Now tht 'someValue' is set in session using servlet2 which is invoked on some button Click of jsp
servlet2 -->session.setAttribute('cancel',someValue)
Howver I am getting str as null always in servlet1 even after invoking servlet2.

Please note that I am using encodeURL to maintain the session.
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ketaki,

welcome to java ranch !!

I think No.

Once you send request to your Servlet after finish the request and clients get response you get control for another process.
 
ketaki gujarathi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
.. is there no way where i can stop executing the function of a servlet on some external action (For Eg on Cancel button click )...
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly is the function that you want to stop?

Is it being executed by the Thread that called the servlet originally or has a new Thread been created?

Are both servlets in the same web application?

Bill
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11886
198
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without knowing the answers to the questions asked by William, it is hard to provide answers.

As Nishan states, the normal processing through a web application is a request generates a response, which does not allow the possibility of user canceling the operation.

This might be bypassed in the cases of a lengthy server side process by utilizing Ajax requests. In which case, as long as you develop something server side to handle this, the client browser would still be responding to user interactions, so it could send some another request to the server to tell it to cancel the job. You would have to ensure that interrupting the server process did not result in invalid data on the server side.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11886
198
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William Brogden wrote:What exactly is the function that you want to stop?

My guess - the report process that Manisha is also asking about - apparently it is taking some time for the report to be built on the server before it gets sent to the client.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic