티스토리 뷰

휴지통/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>

 

 

'휴지통 > JSP' 카테고리의 다른 글

context_test  (0) 2013.05.27
session내장객체  (0) 2013.05.24
JSP 내장객체(내장변수,기본객체)  (0) 2013.05.24
config, application  (0) 2013.05.24
config_test  (0) 2013.05.24
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함