Go Back   Java Programming Forums > Java Standard Edition Programming Help > Threads


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-02-2010, 04:27 AM
sun sun is offline
Junior Member
 

Join Date: Feb 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
sun is on a distinguished road
Question control thread using javascript button in jsp

how to control threads in a jsp page using javascript button?



when i click on a button, i should be able to pause a thread.
i have tried writing code in a function using <% ... %> tags, but they are executed automatically on page load. and when i click on the button, nothing happens.



Reply With Quote Share this thread on Facebook
Sponsored Links
Java Training from DevelopIntelligence
  #2 (permalink)  
Old 02-02-2010, 08:07 AM
Json's Avatar
Super Moderator
 

Join Date: Jul 2009
Location: Manchester, United Kingdom
Posts: 1,181
Thanks: 55
Thanked 137 Times in 133 Posts
Json will become famous soon enoughJson will become famous soon enoughJson will become famous soon enough

I'm feeling Happy
Default Re: control thread using javascript button in jsp

If you want this seamless so that the brower doesnt refresh the page when you click the button you will have to create an AJAX call.

Using jQuery for instance this makes it all really easy. See Ajax – jQuery API for more information.

Once you make the ajax call you need to have a servlet or something receiving this call and then just take it from there to pause the running state of the thread in question.

// Json
Reply With Quote
  #3 (permalink)  
Old 02-02-2010, 08:37 AM
sun sun is offline
Junior Member
 

Join Date: Feb 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
sun is on a distinguished road
Default Re: control thread using javascript button in jsp

i have not done programming using AJAX yet.
it seems to be able to solve the problem.
will give it a try.
thanks.
Reply With Quote
  #4 (permalink)  
Old 03-02-2010, 03:00 AM
sun sun is offline
Junior Member
 

Join Date: Feb 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
sun is on a distinguished road
Question Re: control thread using javascript button in jsp

Quote:
Originally Posted by Json View Post
If you want this seamless so that the brower doesnt refresh the page when you click the button you will have to create an AJAX call.

Using jQuery for instance this makes it all really easy. See Ajax – jQuery API for more information.

Once you make the ajax call you need to have a servlet or something receiving this call and then just take it from there to pause the running state of the thread in question.

// Json

thanks for the advice.
but as i went through the Ajax books, i saw that only text-data can be passed between a server and client using jsp.
how can i locate the thread in the server and then control it ?
please suggest some coding example..
Reply With Quote
  #5 (permalink)  
Old 04-02-2010, 07:21 AM
Json's Avatar
Super Moderator
 

Join Date: Jul 2009
Location: Manchester, United Kingdom
Posts: 1,181
Thanks: 55
Thanked 137 Times in 133 Posts
Json will become famous soon enoughJson will become famous soon enoughJson will become famous soon enough

I'm feeling Happy
Default Re: control thread using javascript button in jsp

Well I guess you start up the server and start each thread you want to control, you then save these threads in lets say a map so that you have a reference to them.

Whenever you then make an AJAX request to the server like so for instance.

Quote:
http://myserver.location.domain/stopthread.action?thread=<NAME_OR_ID>
The NAME_OR_ID will then be used on your server side to look up the thread from the map and set whatever status you need to paused or whatever

Hope that makes any sense.

// Json
Reply With Quote
Reply

Tags
javascript, jsp, thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Similar Threads
Thread Thread Starter Forum Replies Last Post
Control Browser Back Button Ganezan JavaServer Pages: JSP & JSTL 2 01-01-2010 12:21 PM
control Browser Back Button Ganezan JavaServer Pages: JSP & JSTL 0 30-12-2009 11:49 AM
process control ttsdinesh Java Native Interface 6 27-10-2009 10:29 PM
how to put session in javascript rajani JavaServer Pages: JSP & JSTL 2 08-07-2009 05:46 PM
javascript issue in eclipse JEE ganymede 3.4.2 katty Java IDEs 3 18-05-2009 08:45 AM


100 most searched terms
Search Cloud
2d arraylist java actionlistener actionlistener in java actionlistener java addactionlistener addactionlistener in java addactionlistener java applications of oops could not create java virtual machine xp double format java double to int double to int java double to integer in java double to integer java eclipse shortcut keys eclipse tutorial for beginners exception in thread "awt-eventqueue-0" java.lang.outofmemoryerror: java heap space exception in thread "main" java.lang.nullpointerexception exception in thread "main" java.lang.outofmemoryerror: java heap space format double java get mouse position java java 2d arraylist java actionlistener java addactionlistener java convert list to map java double format java double formatting java double to int java double to integer java format double java forum java forums java get mouse position java list to map java mouse position java programming forum java programming forums java programming help java sendkeys java two dimensional arraylist java.lang.classformaterror: truncated class file java.lang.outofmemoryerror: java heap space java.util.arraylist jbutton actionlistener jtextarea font jtextfield font size jxl.read.biff.biffexception: unable to recognize ole stream programming mutators and generics two dimensional arraylist java writing ipod apps

All times are GMT. The time now is 09:17 AM.
Powered by vBulletin® Copyright ©2000-2009, Jelsoft Enterprises Ltd.