Tuesday 25 March 2014

JSP Interview Questions

1. How to create a Thread safe JSP page?
Ans: Theoretically, JSP pages can be indicated as threadsafe via the isThreadSafe page directive attribute

2. How to catch RunTimeException in JSP?

Ans: http://www.tutorialspoint.com/jsp/jsp_exception_handling.htm

2. What is the difference between request.getSession() and request.getSession(true)?

Ans: There is no difference at all.

3. Why we don't define constructor in servlets?

Ans: 1. HttpServlet is a dynamically loaded class so any argument can't be passed in the constructor.
2. Servlet is an interface, we can't define a constructor for that.