File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Threads in j2ee Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Threads in j2ee" Watch "Threads in j2ee" New topic
Author

Threads in j2ee

Raef Kandeel
Ranch Hand

Joined: Aug 05, 2007
Posts: 87
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


SCJP, SCWCD
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29219
    
135

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Raef Kandeel
Ranch Hand

Joined: Aug 05, 2007
Posts: 87
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29219
    
135

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

Joined: Aug 05, 2007
Posts: 87
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Threads in j2ee
 
Similar Threads
Regd JDBS Statement...
Unexpected thread behavior
Passing Score?
int is atomic!!!
Dates in Oracle functions...