JSP Interview Questions and Answers
Ques 46. What is the difference between variable declared inside a declaration and variable declared in scriplet?
Ans. Variable declared inside declaration part is treated as a instance variable and will be placed directly at class level in the generated servlet.
<%! int k = 10; %>
Variable declared in a scriptlet will be placed inside _jspService() method of generated servlet.It acts as local variable.
int k = 10;
Ques 47. How is scripting disabled?Ans. Scripting is disabled by setting the scripting-invalid element of the deployment descriptor to true. It is a subelement of jsp-property-group. Its valid values are true and false. The syntax for disabling scripting is as follows:
Ques 48. What is the difference between ServletContext and PageContext?Ans. ServletContext: Gives the information about the container and it represents an application.
PageContext: Gives the information about the Request and it can provide all other implicit JSP objects.
Ques 49. What is JSP Compiler and where are compiled JSP Java files?Ans. JSP are automatically compiled at runtime.
Most helpful rated by users: