cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Green" <>
Subject Re: Newbie - session/request object at class level ?
Date Wed, 02 Aug 2000 18:06:57 GMT
ultan o'carroll <> wrote:
>Im getting errors when I try to use a tag library that Im developing
>(trying to develop I should say)
>telling me that I have "undefined variable or class names" (sepcifically
>request, session, log)
>when I try to use these objects in the class level logic element of the
>library (see <!-- ** here ** --> comments )-

They are passed as parameters to the implicit page generation method, and by 
default can only be accessed inside the <page> element, or whatever your 
root page element is called inside <xsp:page>. But you can easily pass them 
outside by passing them to methods as arguments or assigning them to 
instance variables. Instance variables in the XSP page are NOT recommended 
for this purpose, as they can easily cause all sorts of problems, including 
nasty hard-to-track threading problems.

Final "variables" are safe though. For example, an exception to the above 
paragraph is servletContext, which is a final instance variable which is set 
automatically - you don't have to do anything to be able to use it anywhere 
on the XSP page.

Example for session:

  public void myMethod (HttpSession session) {
    // ...

  myMethod (session);

Robin Green
i-tao Ltd.
4 Skyline Village
London E14 9TS
United Kingdom
Phone +44 20 7537 2233  Fax +44 70 8081 5118

Get Your Private, Free E-mail from MSN Hotmail at

View raw message