제일 먼저 

http://www.servlets.com/cos/ 에서 cos-26Dec2008.zip 파일을 다운 받아서


c : 아파치 폴더에 있는 lib 에 압축을 풀어서 넣는다.



form6.html


<!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>조으디조으디조으디  간나새뀌</title>

</head>

<body>


<form action="form6.jsp" method="post" enctype="multipart/form-data">


파일 : <input type = "file" name="file"><br>

설명 : <input type = "text" name="desc"><br>

<input type="submit" value="업로드(해킹)">

<input type="reset" value="취소">


</form>

</body>

</html>






form6.jsp

<%@ page language="java" contentType="text/html;charset=EUC-KR"

pageEncoding="EUC-KR"%>

<%@ page import="com.oreilly.servlet.MultipartRequest,

com.oreilly.servlet.multipart.DefaultFileRenamePolicy,java.io.File" %>


<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">

<title> 업로드가 완료 되었다 조으디 ㅋㅋ</title>

</head>

<body>

<% 

String savePath = application.getRealPath("/upload");

int sizeLimit = 5*1024*1024;

MultipartRequest mr = new MultipartRequest(request,savePath,sizeLimit,"euc-kr",new

DefaultFileRenamePolicy());


File file = mr.getFile("file");

String fileName = file.getName();

long fileSize = file.length();

if(fileName == null){

out.println("파일 업로드 실패");

}else{

out.println(savePath + "<br/>");

out.println("파일명 : " + fileName + "<br/>");

out.println("파일크기 : " + fileSize + "<br/>");

out.println("설명 : " + mr.getParameter("desc") + "<br/>");

}

%>


</body>

</html>

블로그 이미지

김진리

,

checkbox 로 한꺼번에 여러개를 전송 할 시 사용 된다.


form3.html


<!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> 핸드폰 고르는 예제</title>

</head>

<body>



<form action = "form3.jsp" method="get" name="textform">

제품선택 : <br>

<input type="checkbox" name="chk1" value="갤럭시튀튀튀">갤럭시튀튀튀<br/>

<input type="checkbox" name="chk2" value="뉴아이패득">뉴아이패득<br/>

<input type="checkbox" name="chk3" value="킨들파이옥">킨들파이옥<br/>

<input type="submit" value="전송">

<input type="reset" value="초기화">


</form>



</body>

</html> 






form3.jsp


<%@ page language="java" contentType="text/html;charset=EUC-KR"

pageEncoding="EUC-KR"%>

<%@ page import="java.util.Enumeration" %>

<% request.setCharacterEncoding("euc-kr"); %>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">

<title>당신의 선택은?? 두둥</title>

</head>

<body>

당신의 선택은...

<% 

Enumeration enums = request.getParameterNames();

while ( enums.hasMoreElements()){      

  enums 가 값을 가지고 있는지 물어서 있으면 true / while 문이 반복된다.

String name = (String)enums.nextElement();      

그다음의 enums 가 가지고 있는 element 들을 string 으로 형 변환 시켜 저장!

if(name.startsWith("chk")) {

String value = request.getParameter(name);

out.println("<b>" + value + "<b> , ");

}

}

%> 입니다.



</body>

</html>

블로그 이미지

김진리

,

form1.html

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">

<title>해커 가입</title>

</head>

<body>

해킹할 ID와 password 및 자기소개를 입력 해라!

<form action= "form1.jsp" method = "post" name = "textform">

ID : <input type = "text" name = "id"> <br/>

Password : <input type="password" name = "pw"> <br/>

자기소개 <br/>

<textarea name="desc" rows="4" cols="50"></textarea><br>


<center>

<input type = "submit" value="전송" name="submitbtn">

<input type = "reset" value="초기화" name="resetbtn">

</center>

</form>

</body>

</html>






form1.jsp


<%@ page language="java" contentType="text/html;charset=EUC-KR"

pageEncoding="EUC-KR"%>

<%

request.setCharacterEncoding("utf-8");    //한글처리용

%>



<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">

<title>Form 처리 입니다아다아다다당 ㅋㅋ</title>

</head>

<body>


입력 정보 입니다.


ID : <%= request.getParameter("id") %>  <br/>

Password : <%= request.getParameter("pw") %>

자기소개 : <%= request.getParameter("desc") %>


</body>

</html>

블로그 이미지

김진리

,



Connector 에서 Add Attribute -> new attribute 해서 URIEncoding , euc-kr 을 생성한다. 

'개발자 > JSP' 카테고리의 다른 글

홈페이지 Login & targer From 예제  (0) 2013.02.04
JSP 사진,파일 upload 예제  (0) 2013.02.01
JSP Enumeration 사용 예제  (0) 2013.02.01
JSP post 전송 폼  (0) 2013.02.01
이클립스의 라인 색깔 나오게 하기  (0) 2013.01.31
블로그 이미지

김진리

,

맨 상위 메뉴에서 Window 에서 

따라하시면 됩니다.




바뀐 이클립스 라인 모습


블로그 이미지

김진리

,