휴지통/JSP

context_test

LeReve 2013. 5. 24. 14:16

 

context_test.jsp 

 <%@page import="java.io.FileReader"%>
<%@page import="java.io.BufferedReader"%>
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<%-- context_test.jsp --%>
<body>
 <h3>context테스트</h3>
 <%
  out.print(application.getInitParameter("workspace"));
 
  //String path = application.getRealPath("");
  //D:\workspace\TomTest2
  
  String path = application.getRealPath("/");
  //D:\workspace\TomTest2\
  
  //String path = application.getRealPath("/0524");
  //D:\workspace\TomTest2\0524
  
  out.print("<br>path="+path+"<br>");
  
  BufferedReader br = new BufferedReader(new FileReader(path+"0524/a.txt"));
  
  String str;
  out.print("<br>");
  while((str = br.readLine())!=null){
   out.print(str+"<br>");
  }
  
  //application.log(Exception arg0, String arg1)//exception 정보를 같이 남길때 사용
  application.log("접속정보"+request.getRemoteAddr());//C:\Tomcat 6.0\logs\localhost.2013-05-24(날짜)
  
  String info =application.getServerInfo();//서블릿 컨테이너 정보
       int ver1=application.getMajorVersion();
       int ver2=application.getMinorVersion();
       out.print("서버정보: "+ info+"<br>");
       out.print("서블릿API버전: "+ ver1+"."+ver2);
  
  br.close();
 %>
</body>
</html>