• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Threads in j2ee

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is it prohibited to use threads in jsp's. If I have a class, not a bean, that uses threads. Just the line:-



is it considered a bad practice?

Thanks
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Raef,
It's considered bad practice to have any code in a JSP. It's considered horrible practice to have a sleep statement in a JSP.

A JSP is supposed to be the view layer. All logic should be done in a servlet (or code called by a servlet) before forwarding to the JSP.

What are you trying to accomplish? Maybe we could suggest a better way.
 
Raef Kandeel
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh Oh. That was a mistake. No, I used Thread.sleep in a java class, not in JSP. You can replace JSP with J2EE. Thanks for your reply.
[ April 12, 2008: Message edited by: Raef Kandeel ]
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Raef,
That's a more interesting question.

Using threads in EJBs is not considered good practice. In a servlet, I've seen it. I wouldn't call it good practice, but there are a couple uses. All of which can now be replaced with AJAX or queues.

I think the real question is whether thread.sleep is the best way for what you are trying to accomplish. Feel free to give an example.
 
Raef Kandeel
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am aware that some web application servers have schedulers that fulfill the same functionality. I know that WAS does for example. Is there any simpler solution. What I am trying to achieve here is automatically retrieve some rss feed every specified time interval. Thanks again.
[ April 14, 2008: Message edited by: Raef Kandeel ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic