Tuesday, 5 April 2016

Variable declared inside a declaration part vs. inside scriptlet


Variable declared inside declaration part is treated as a global variable that means after convertion jsp file into servlet that variable will be in outside of service method or it will be declared as instance variable and the scope is available to complete jsp and to complete in the converted servlet class.
<%! int age = 30; %>


Whereas if you declare a variable inside a scriptlet that variable will be declared inside a service method and the scope is with in the service method.
<% int age = 30; %>

No comments:

Post a Comment

Note: only a member of this blog may post a comment.