Prepare Interview

Exams Attended

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

JSP Interview Questions and Answers

Test your skills through the online practice test: JSP Quiz Online Practice Test

Related differences


Ques 36. What's a better approach for enabling thread-safe servlets and JSPs? SingleThreadModel Interface or Synchronization?

Although the SingleThreadModel technique is easy to use, and works well for low volume sites, it does not scale well. If you anticipate your users to increase in the future, you may be better off implementing explicit synchronization for your shared data. The key however, is to effectively minimize the amount of code that is synchronized so that you take maximum advantage of multithreading.

Also, note that SingleThreadModel is pretty resource intensive from the server’s perspective. The most serious issue however is when the number of concurrent requests exhaust the servlet instance pool. In that case, all the unserviced requests are queued until something becomes free – which results in poor performance. Since the usage is non-deterministic, it may not help much even if you did add more memory and increased the size of the instance pool.

Is it helpful? Add Comment View Comments

Ques 37. What is the difference between variable declared inside a declaration and variable declared in scriplet?

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;

Is it helpful? Add Comment View Comments

Ques 38. How is scripting disabled?

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:


Is it helpful? Add Comment View Comments

Ques 39. What is the difference between ServletContext and PageContext?

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.

Is it helpful? Add Comment View Comments

Ques 40. What is a JSP and what is it used for?

Java Server Pages (JSP) is a platform independent presentation layer technology that comes with SUN s J2EE platform. JSPs are normal HTML pages with Java code pieces embedded in them. JSP pages are saved to *.jsp files. A JSP compiler is used in the background to generate a Servlet from the JSP page.

Is it helpful? Add Comment View Comments

Most helpful rated by users:

©2023 WithoutBook