• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpServletResponse

 
Terry McKee
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was going through one of the examples in the SCWCD Exam Study Kit by Hanumant Deshmukh and Jignesh Malavia. The example is on p268.
...
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
...
synchronized (request)
{
...
}
}
I don't understand when you would ever need to synchronize on request? The request variable is a local variable. Unless you are passing the request variable explicitly to another thread I don't see why this would be done?
 
Terry McKee
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any thoughts on this?
 
Terry McKee
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would really like to find out what other people have discovered on this issue.
 
Raj Paul
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya,
There is no need to synchronize the request object in service method.
Raj Paul
 
Jignesh Malavia
Author
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Terry!
Yes, you are right. The request scoped objects are always thread-safe. But the request object in the servlet code on p268 is synchronized because it is explained in the context of JavaBeans as discussed here http://www.manning.com/ao/readforum.html?forum=scwcdao&readthread=18
You can also post more questions about the book or read answers to other queries at http://www.manning.com/getpage.html?project=deshmukh&filename=forum.html
Hope, the bookproves helpful to you.
-j
 
Terry McKee
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies. I took a look at the link you provided Jignesh. I am still a little confused on this point, but I'll figure it out. Anyway, your book is really great, I have gotten a lot out of it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic