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

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-02-2010, 05: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
  #2 (permalink)  
Old 02-02-2010, 09:07 AM
Json's Avatar
Super Moderator
 

Join Date: Jul 2009
Location: Manchester, United Kingdom
Posts: 861
Thanks: 31
Thanked 112 Times in 108 Posts
Json 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
Sponsored Links
  #3 (permalink)  
Old 02-02-2010, 09: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, 04: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, 08:21 AM
Json's Avatar
Super Moderator
 

Join Date: Jul 2009
Location: Manchester, United Kingdom
Posts: 861
Thanks: 31
Thanked 112 Times in 108 Posts
Json 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 01:21 PM
control Browser Back Button Ganezan JavaServer Pages: JSP & JSTL 0 30-12-2009 12:49 PM
process control ttsdinesh Java Native Interface 6 27-10-2009 11: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
2 dimensional arraylist java 2d arraylist java actionlistener actionlistener in java actionlistener java actionlistener jbutton addactionlistener addactionlistener java avatar hardware id convert double to integer java double format java 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.outofmemoryerror: java heap space format double java get mouse position java hardware id avatar java 2 dimensional arraylist java 2d arraylist java actionlistener java addactionlistener java button actionlistener java convert double to int java convert list to map java double format java double to int java double to integer java for beginner eclippse java format double java forum java forums java get mouse position java ipod touch java jbutton java list to map java programming forum java programming forums java sendkeys java.lang.reflect.invocationtargetexception java.util.arraylist jbutton actionlistener jbutton java programming forums string to int java two dimensional arraylist java writing apps for ipod touch

All times are GMT. The time now is 02:12 PM.
Powered by vBulletin® Copyright ©2000-2009, Jelsoft Enterprises Ltd.