How to Improve Servlet Performance

Cache static data using jspInit() method. Release static data in jspDestroy() method. To concatenate string use, StringBuffer. Do not use println() method. Do not use PrintWriter to send binary data. Use ServletOutputStream. Always flush data in sections. Use getLastModified() method to handle browser and server cache. Use application server cache. Use session in following order: … Read more

What is HTTP Session in Servlets

Session tracking in Servlets is done by using Interface HttpSession. It helps to identify a client throughout many page requests or visiting a website and to store details about that client. One of the recommended approaches is HTTP session. A request is being identified by the session which is originated from similar browser during the … Read more

Why we are used setMaxAge() and getMaxAge() in Cookies

Gets/sets how much time (in seconds) should elapse before the cookie expires. If you don’t set this, the cookie will last only for the current session (i.e. until the user quits the browser), and will not be stored on disk. In Java, specifically in the context of web development using servlets or JSP (JavaServer Pages), … Read more

What is Cookies and what is the use of Cookies

A “cookie” is a small piece of information sent by a web server to store on a web browser so it can later be read back from that browser. This is useful for having the browser remember some specific information. to create a temporary session where the site in some way “remembers in the short term” what … Read more

When init() and Distroy() will be called

init() is called whenever the servlet is loaded for the first time into the webserver.it performs certain one time activities which are required during the lifetime of the servlet.It may be some initialisation of variables or a database connection. Destroy will be called whenever the servlet is removed from the webserver. Various resources which are … Read more