import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.util.Calendar; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class MyDate extends HttpServlet { private static final long serialVersionUID = 1L; @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html; charset=UTF-8"); PrintWriter out = response.getWriter(); out.println(""); Calendar cal = Calendar.getInstance(); out.printf("%d時%d分%d秒%n", cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND)); out.printf("
"); File dir = new File("."); out.printf("dir = %s%n", dir.getCanonicalPath()); out.println(""); out.close(); } }