Write a servlet which displays a message “I LOVE MY MOM”?
import javax.servlet.*;
import java.io.*;
public class First extends GenericServlet {
public First() {
System.out.println("I AM FROM DEFAULT CONSTRUCTOR...");
}
public void init() {
System.out.println("I AM FROM init METHOD...");
}
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
System.out.println("I LOVE MY MOM...");
System.out.println("I AM FROM service METHOD...");
}
public void destroy() {
System.out.println("I AM FROM destroy METHOD...");
}
}
import java.io.*;
public class First extends GenericServlet {
public First() {
System.out.println("I AM FROM DEFAULT CONSTRUCTOR...");
}
public void init() {
System.out.println("I AM FROM init METHOD...");
}
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
System.out.println("I LOVE MY MOM...");
System.out.println("I AM FROM service METHOD...");
}
public void destroy() {
System.out.println("I AM FROM destroy METHOD...");
}
}
Java Resources are available for Download from below
Category: Interview Question, JavaSE, Programs, Servlet
0 comments