Write a servlet which displays current system date and time?

package ds;
import javax.servlet.*;
import java.io.*;
import java.util.*;
public class DateServ extends GenericServlet {
 public DateServ() {
  System.out.println("SERVLET LOADED...");
 public void init() {
  System.out.println("I AM FROM init METHOD...");
 public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
  PrintWriter pw = res.getWriter();
  Date d = new Date();
  String s = d.toString();
  pw.println("<h1> WELCOME TO SERVLETS <h1>");
  pw.println("<h2> CURRENT DATE & TIME IS : " + s + "<h2>");
 public void destroy() {
  System.out.println("I AM FROM destroy METHOD...");



No comments:

Post a Comment