Write a java program write a servlet displaying current date & time also wish the user accordingly


import java.io.*;

import java.sql.*;

import java.util.*;

import java.util.Date;

import javax.servlet.*;

public class Calender extends GenericServlet

{

            int hours;

            public void service(ServletRequest r1,ServletResponse r2)throws ServletException,IOException

            {

                        r2.setContentType("text/html");

        PrintWriter pw=r2.getWriter();

                        pw.println("

                        pw.println("

                pw.println("
");

                        Date d1=new Date();

                        pw.println(d1);

                        pw.println("
");

                        long ms=d1.getTime();

                        pw.println("
");

                        pw.println(ms);

                        pw.println("
");

                        GregorianCalendar today=new GregorianCalendar();

                        hours=today.get(Calendar.HOUR_OF_DAY);

                        if(hours>=6 && hours<=12)

                        {

                                    pw.println("Good Morning!!!.....");

                        }


                        else if(hours>=12 && hours<=18)

                        {

                                    pw.println("Good Afternoon !!!.....");

                        }

                        else if(hours>=18 && hours<=20)

                        {

                                    pw.println("Good Evening !!!......");

                        }

                        else

                        {

                                    pw.println("Good Neight!!!.....");

                        }

           

            pw.println("

");

            pw.println("

");

            }

}
Write a java program write a servlet displaying current date & time also wish the user accordingly Write a java program write a servlet displaying current date & time also wish the user accordingly Reviewed by on April 27, 2015 Rating: 5
Powered by Blogger.