Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Variables in Portlets

 
John Lincoln
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All,
I have small question, can we declare variable at class level ?


Generally in servlets we don't declare instance variables.

Is the samething applies to Portlets. I am little confused. Portlets are based on portletrequest & response, not on HttpRequest and HttpResponse.

Should we not declare instance variables for portlets ? Can someone who has clear understanding explain it.

I will really appreciate your help
 
Ashish Sarin
author
Ranch Hand
Posts: 432
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,

Your understanding is correct - portlets are like servlets and you should not declare instance variables in the portlet class. The reason is the same as in case of servlets - multiple threads might be accessing the same portlet instance.

regards
ashish
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic