• Post Reply Bookmark Topic Watch Topic
  • New Topic

Newbie Threading Question

 
scottie zman
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm getting ready to start a Java SOAP server that will integrate with a pre-existing ASP front-end. The servlet will recieve tons of traffic as it sends XML to dozens of sites.
While I understand basically how threading works, I'm wondering what issues I need to watch out for with beans. When I use beans from JSP's, I call them up within the request scope of the page. Does this guarantee that each bean will be used separately from one another? If not then what do I need to do to ensure this?
Also, when using servlets rather than a JSP to do this, how do I guarantee that each instance will be thread-safe.... and if I want to, how do I make various properties available to other instances?
Thanks
Zman
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like an ambitious project!
If you have a bean with request scope, JSP creates a new instance for every request.
Of course, a JSP is a servlet, so the only difference is what the JSP API does for you. In a servlet you have to manage your own bean and other objects. Just remember that instance variables in the servlet are visible to all request Threads.
You have lots of possible choices for managing data to be communicated between requests. A singleton object with synchronization on methods that modify or read the stored data is typical. Sun recently published a book - Core J2EE Patterns - that has a lot of design discussion
Bill
------------------
author of:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!