Results 1 to 3 of 3

Thread: Servlets: Retriving current date and time

  1. #1

    Thread Starter
    Member RyanY's Avatar
    Join Date
    Mar 2001
    Location
    Singapore
    Posts
    33
    How would i go about retriving the current Date and Time in a Servlet? Thanks!

  2. #2
    Hyperactive Member
    Join Date
    May 2000
    Posts
    367

    Try this and let me know

    This will get the current time and date and update every 10 seconds

    Let me know if this works for ya.

    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;

    public class ClientPull extends HttpServlet {

    public void doGet(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {
    res.setContentType("text/plain");
    PrintWriter out = res.getWriter();

    res.setHeader("Refresh", "10");
    out.println(new Date().toString());
    }
    }

  3. #3

    Thread Starter
    Member RyanY's Avatar
    Join Date
    Mar 2001
    Location
    Singapore
    Posts
    33
    Thanks for your idea! Its great as well. I figured out another way. But I'll keep your idea somewhere to use in the future. hehe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width