Somasundaram,
Declaration var : vars defined like <%! int nthUser=0; %>
Scriplet var : vars defined like <%
String userName=null; %>
Scriplet vars are like local vars defined inside servive(..) method of a Servlet. They are local to only servive(..) method and not known outside. Also whenever a browser calls a jsp page, these scriplet vars are initialized each and every time freshly!
They don't maintain their old vales between requests. In other words it is alive only for one request. They can be accessed between other <% %> only.
Declaration vars means PAGE level vars. <%! %> means you are declaring OUTSIDE of service(...) methods and are global to all other methods defined within this jsp page.
This also means <%! ...%> vars maintain their vals BETWEEN requests. They are persistant vars.
Simillarly if you define a method <%! public void sayHello() {...} %> , it means it is a whole new method written outside of service(...) method and can be accessed inside scriplets <% ..%> also. Got it!
Also note that, the implicit objects of a jsp page which are 'request', 'response','session'... etc are alive only inside scriplets <% %>, meaning inside service(....) method. Not outside. So you can't write a code like this. <%! session.getAttribute("login"); %> It is illegal.
But you can write a global method with HttpRequest object as parameter and pass the request object from a scriplet like this.
This code is legal!
regds
maha anna
It is like this
[This message has been edited by maha anna (edited March 23, 2001).]