⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timeservlet.java

📁 java3D game engine design of the source [three-dimensionalvirtualrealitynetworkprogram] - "virtual
💻 JAVA
字号:
// TimeServlet.java
// Andrew davison, June 2003, dandrew@ratree.psu.ac.th

/* Return a text page to the client containing the 
   current date and time.
*/


import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.Date;
import java.text.SimpleDateFormat;


public class TimeServlet extends HttpServlet 
{
   public void doGet( HttpServletRequest request,
                      HttpServletResponse response )
      throws ServletException, IOException
   {
      // response.setContentType( "text/txt" );  // content type

      SimpleDateFormat formatter = 
			new SimpleDateFormat("d M yyyy HH:mm:ss");
      Date today = new Date();
      String todayStr = formatter.format(today);
      System.out.println("Today is: " + todayStr);

      PrintWriter output = response.getWriter();
      output.println( todayStr );  // send date & time
      output.close();
   }

} // end of TimeServlet class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -