MY mENU


Thursday 22 March 2012

Jsp Interview Questions-part4

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 there a way to reference the "this" variable within a JSP page? 

Yes, there is. The page implicit object is equivalent to "this", and returns a reference to the generated servlet. 

Can you make use of a ServletOutputStream object from within a JSP page? 
Yes . By using getOutputStream() method on response implicit object we can get it.

What is the page directive is used to prevent a JSP page from automatically creating a session? 
session object is by default available to the JSP. We can make it unavailable by using page directive as follows.
<%@ page session="false"> 

 What's a better approach for enabling thread-safe servlets and JSPs? SingleThreadModel Interface or Synchronization? 
            Synchronized keyword is recommended to use to get thread-safety.

No comments:

Post a Comment