Java Servlet Interview Questions

Connect with

In the previous post , I posted about JSP interview question and now turn for java Servlet frequently asked interview question for all the level.

what is differences between HttpServletRequest’s getSession(), getSession(true) and getSession(false) methods?

  • HttpServletRequest.getSession(): it returns the current HttpSession associated with this request, or if the request does not have a session, creates new one. If no bolean argument provide it means HttpServletRequest.getSession(true)
  • HttpServletRequest.getSession(true): it returns the current HttpSession associated with this request, if there is no current session, returns a new session.
  • HttpServletRequest.getSession(false): it returns the current HttpSession associated with this request, if there is no current session, returns null.

Suggestions are welcome to rectify error, to improve the list of questions and to share the list of questions to include in this page.


Connect with

Leave a Reply

Your email address will not be published. Required fields are marked *