• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between declarative and scriptlet

 
Jayanth Mathavan
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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64716
86
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic