ServletTest.java 저장(메모장으로)


도스창에서 C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\servletTest\WEB-INF\src

폴더로 이동


"javac -d ../classes *.java 명령어로 컴파일


아무메시지가 없으면 정상적 수행 




ServletTest.java


import javax.servlet.*;

import javax.servlet.http.*;

import java.io.*;

import java.util.Calendar;



public class ServletTest extends HttpServlet{

public void doGet(HttpServletRequest request, HttpServletResponse response)

throws IOException{

response.setContentType("text/html");

response.setCharacterEncoding("euc-kr");

Calendar c = Calendar.getInstance();

int hour=c.get(Calendar.HOUR_OF_DAY);

int minute=c.get(Calendar.MINUTE);

int second=c.get(Calendar.SECOND);

PrintWriter out= response.getWriter();

out.write("<HTML><HEAD><TITLE>ServletTest</TITLE></HEAD>");

out.write("<BODY><h1>");

out.write("현재시각은");

out.write(Integer.toString(hour));

out.write("시 ");

out.write(Integer.toString(minute));

out.write("분 ");

out.write(Integer.toString(second));

out.write("초입니다. ");

out.write("</h1></body></html>");

out.close();


}

}



블로그 이미지

왕왕왕왕

,