• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

decalring static varibles in JSP

 
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Can any one tell me is there any way to declare STATIC variables in JSPs?

In Head First Servlets and JSP, it is written that when container translets JSPs into Servlets it automatically creates one static varible and one static method of its own. May I know why it happens like that any technical reasons??

And one more question is why there is any IMPLEMENTS in JSP. If we are in a sitivation where we are to implemet runnable kind of interface in jsp what should we do?

Thanks in advance

Regards,
Rahul Roy.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you can declare static variables by placing them in a <%! %> construct, which creates class-level declarations. Be careful doing so, as accidentally creating class-level read/write instance variables in such a construct can introduce thread-safety issues into your JSPs.

In fact, at this stage of the game, unless you are stuck in a pre-JSP 2.0 world, you should be migrating away from using any scriptlet constructs in your pages at all in favor of the JSTL and EL.
[ August 21, 2006: Message edited by: Bear Bibeault ]
reply
    Bookmark Topic Watch Topic
  • New Topic