Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Difference between declarative and scriptlet  RSS feed

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Am a bit confused about the functionality of a declarative tag and a scriptlet tag.
example of a declarative is <%! int x=10; %>
and Scriplet is <% public void method1(int x, int y){ int a = x+y; } %>

Can we use java codes inside a declarative tag? If so, then whats the difference between a declarative tag and a scriptlet tag?

Thanks and Regards,
Jayanth Mathavan.
[ August 16, 2007: Message edited by: Jayanth Mathavan ]
 
Author and ninkuma
Marshal
Posts: 66797
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I must preface this by stating that at this point in time, you should be using JSP 2.0 and shouldn't be using either of the declarations or scriptlets in your pages any longer.

That said, scriptlets are code fragments that are collected to form the service method of the JSP along with the statements needed to emit the template text.

Declarations are placed at class-level rather than within a method.

Declarations are the easiest way to introduce threading bugs into yout JSP pages and should be avoided unless absolutely necessary even in older JSP versions.
[ August 16, 2007: Message edited by: Bear Bibeault ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!