본문 바로가기
JavaWeb

파일 읽기

by 캡틴노랑이 2015. 9. 7.
반응형

첨부파일 (1)

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
    <%@page import="java.util.*, java.io.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<% 
int len = request.getContentLength();
byte[] buf =null;
int n=0;
if(len > 0)
{
buf = new byte[len];
n= request.getInputStream().read(buf);
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data">
<input type="hidden" name="oneTwoThree"  value="123" />
<input type="file" name="file" />
<input type="submit" />
</form>
<table border="1">
<tr><td>getContentType()</td><td><%=request.getContentType() %></td></tr>
<tr><td>getContentLength()</td><td><%=len %></td></tr>
<%
out.print("<tr><td>getInputStream(): " + n + "</td><td><pre>"); 
for(int k=0; k< n; k++)
out.print((char)buf[k]);
out.println("</pre></td></tr>");
%>
</table>
aaaa
</body>
</html>
반응형

'JavaWeb' 카테고리의 다른 글

[JSP] include  (0) 2015.09.07
[빌드오류] Access restriction: The type QName is not accessible due to restriction on required library  (0) 2015.09.07
문자열 포맷  (0) 2015.09.07
[JSP] 자주 쓸만한 것들.  (0) 2015.09.07
참고 URL  (0) 2015.09.07

댓글