File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Portals and Portlets and the fly likes Variables in Portlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "Variables in Portlets" Watch "Variables in Portlets" New topic
Author

Variables in Portlets

John Lincoln
Ranch Hand

Joined: Feb 11, 2003
Posts: 192
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

Joined: Nov 20, 2000
Posts: 432
    
    5
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


Author of
Getting started with Spring Framework
Portlets in Action
Spring Roo 1.1 Cookbook
Portlets blogSpring Roo blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Variables in Portlets