javascript - On a get request, how can I start program, and then using another get request stop it? -


i'm running website using java , tomcat. @ high level i'm trying route start button java method makes endless amount of calls other resource. when want stop program push stop button.

i have figured out start part, cannot stop because don't think state of request page gets saved. have few global variables in class think keep getting reset everytime make request. how prevent happening?

@path("/myresource") public class myresource { continuousmethod sample = new continuousmethod() boolean collecting = false; /**  * method handling http requests. returned object sent  * client "text/plain" media type.  *  * @return string returned text/plain response.  */ @get @produces(mediatype.text_plain) @path("/collect") public string startcollection() throws urisyntaxexception {     system.out.println("made here");     sample.start();     collecting = true;     return "collecting"; } @get @produces(mediatype.text_plain) @path("/stopcollect") public string stopcollection() {      sample.close();     collecting = false;     return "finished collecting!";      //return "not collecting"; } } 

make use of sessions instead of global variables.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -