RE: What is the right way of writing the code to get t...
getServletInfo() allows the servlet to return basic information about itself such as author version and copyright. Usage: servlet.getServletInfo() --> Inside doget(..) Or < getServletInfo() > --> Inside JSP
RE: What is the right way of writing the code to get the servlet information using public String getServletInfo()?
Some applets and applications for example the Java Web Server Administration Tool display information about a servlet. This information can include a short description of the purpose of the servlet its author and perhaps its version number. So the Servlet API provides a method to return this information getServletInfo. By default this method returns null. While servlet writers are not required to override this method it is strongly recommended. e.g. : -
public class SimpleServlet extends HttpServlet { ... public String getServletInfo() { return "A simple servlet"; } }