To simplify the development of servlets, SunMicroSystems has given a predifined classes. They are "GenericServlet" and "HttpServlet". The following figure shows the relationship between classes.
relationship between servlet classes. |
From the above figure we can understand that Servlet is an Interface which was implemented by GenericServlet class. And HttpServlet is the sub-class of GenericServlet class. Both HttpServlet and GenericServlet classes are abstract.
People say that there are three ways to develop the servlets. But according to SunMicroSystems, it is recommended to develop a servlet based on HttpServlet class, so that we can remove the redundant code of init(), destroy(), getServletConfig(), getServletInfo(). The following is the servlet based on HttpServlet.
servlet based on HttpServlet |
When we observe the above program, it doesn't have a main() method. Generally servlets doesn't consists a main() method, because servlets are executed by server not by JVM. At the same time in the above program we can see System.out.println("we are in First Servlet"). Since servlet program is executed by server the message "we are in First Servlet" will be displayed in server, which we cannot see. So, in servlet if we would like to display a message, it should be placed in PrintWriter object. The following program shows you, how to use PrintWriter object.
program shows you, how to use PrintWriter object |
There are lots of information about java have spread around the web, but this is a unique one according to me. The strategy you have updated here will make me to get to the next level in big data. Thanks for sharing this.
ReplyDeleteHadoop Training Chennai
Hadoop Training in Chennai
Big Data Training in Chennai
Great job.... Awesome list, just starting a blog and this is going to be a massive help. Thank you!
ReplyDeleteSelenium Training in Chennai
Selenium Training
Automation Testing Training in Chennai
Automation Testing Training
This error message refers to the problem on your hard drive or issues during the process of the reading disk with the operating system. When meeting such an issue, no matter how many times you restart your computer by pressing “Ctrl+Alt+Del” keys, this error still exists. In fact, read disk error is not such a problem that can be solved by a simple restart. In this case, you are very upset and don’t know what should do. Don’t worry, this post will tell you its reasons and some useful solutions below. you must use the windows cannot be installed gpt. And the procedure is very simple for Windows and server users. Only three-step, users could recover the lost, deleted, formatted, corrupt files easy and safe.
ReplyDeleteIt's a nice Article, I liked more, Keep on sharing like this, Really I enjoyed lot.
ReplyDeleteBest Aviation Academy in Chennai
Best Air hostess Training in Chennai
Pilot Training in Chennai
Airport Ground staff Training in Chennai
Airport Flight Dispatcher Trainee in Chennai
RTR - Aero Training in Chennai
Cabin Crew Training in Chennai
Aviation Academy in Chennai
Aviation training institute in Chennai
Aviation Course Training in Chennai
Ground staff Training institute in Chennai
Airhostess Training institute in Chennai
Cabin Crew Course
PRIVATE PILOT LICENCE (PPL) Training in Chennai
COMMERCIAL PILOT LICENCE (CPL) Training in Chennai
Thank you so much for sharing this pretty post,It's a nice Article,
ReplyDeleteseleniumtraining in hyderabad