Servlet Random Information #Java Short Notes

  • Web component information sharing: web context (ServletContext), request, session, and page
  • ServletContext – Scope: entire web-application (Servlets & JSPs)
  • page/PageContext : A single point of access for many of the attributes of a JSP page
  • For each access of the servlet a thread is created. In applications a thread can be accessed concurrently by many threads.
  • If the servlet accesses and edits some external resources, then data inconsistency, and data loss may occur
  • Synchronized access should help:
  • public class TestServlet extends HttpServlet implements SingleThreadModel will provide synchronization and concurrency
  • In JSP, you can include – to provide thread safety
  • For SingleThreadModel: you still have to synchronize access to class variables and to any shared resources that are stored outside the servlet. example:
     synchronized(sharedResource) { }
  • For high-traffic servlets, you should use explicit synchronization blocks rather than implementing SingleThreadModel
  • Synchronization is only an issue if the servlet accesses external data resources — returns data from another source: not for a servlet that just performs a task with no data access

From: http://sitestree.com/?p=4966
Categories:Java Short Notes
Tags:
Post Data:2007-03-19 19:26:45

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada