<%@ 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>
<body>
<form>

분류 :

<select name="kind">

<option value="A" <% if(request.getParameter("kind")!=null) { if(request.getParameter("kind").equals("A") ) {%>selected<% } }%> >A항목</option>

<option value="B"<% if(request.getParameter("kind")!=null) { if(request.getParameter("kind").equals("B") ) {%>selected<% } }%>>B항목</option>

<option value="C"<% if(request.getParameter("kind")!=null) { if(request.getParameter("kind").equals("C") ) {%>selected<% } }%>>C항목</option>

</select>

<input type="submit" value="확인">

</form>


</body>
</html>

Posted by 말없제이
,
<%@ 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>
<body>
<!--
포스트백 : 문서 자기자신에게 자료를 전송하는 형태를 일명 포스트백이라 부른다.
아래처럼 action속성에 문서자기자신의 이름을 지정하는 형태를 포스백이라 부른다.
form태그에서 method를 생략할 경우 기본값은 get이다.
form태그에서 action을 생략할 경우 기본값은 문서 자기자신.
-->
<% request.setCharacterEncoding("euc-kr"); %>
<form method="post" action="Intro09.jsp">
키워드 : <input type="text" name="keyword"  value="<% if(request.getParameter("keyword") != null ) { %><%=request.getParameter("keyword")%><% }  %>">
<input type="submit" value="확인">
</form>
입력한 값 :
<%//폼변수 keyword의 값을 출력
out.println(request.getParameter("keyword"));
%>
</body>
</html>
Posted by 말없제이
,
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!-- Intro07.jsp -->   
<!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>
<body>
<!-- 스파게티코드: 시작과 끝이 전부 html요소에 의해 분리되므로
어지러워서 스파게티코드라 부릅니다...  -->
<table width="650" border="1">
<%
for (int i=1; i<=10; i++)
{
%>
 <tr <% if (i%2==0) {%>bgcolor="yellow"<%} %>>
  <td><%=i %>행</td>
 </tr>
<%
}
%>
</table>
</body>
</html>

*.구구단 연습.
**********   Intro08.jsp   *************
<%@ 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>
<body>
<table border="1" width="650">
<%
 for (int i=1; i<=9; i++)
 {
%>  
<tr <% if (i%2==0) {%>bgcolor="green"<%} %>>
<%
  for (int j=1; j<=9; j++)
  {
%>  
   <td><%=i %>X<%=j %>=<%=(i*j) %></td>
<%
  }
%>
</tr>
<%
 }
%>
</table>
</body>
</html>
Posted by 말없제이
,

<%@ 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>
<body>
<form method="post" action="Intro06pro.jsp">

노래 1 : <input type="text" name="sing"><p/>

노래 2 : <input type="text" name="sing"><p/>

노래 3 : <input type="text" name="sing"></p>

<input type="submit" value="확인">

</form>


</body>
</html>

************    Intro06pro.jsp     ****************
<%@ 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>
<body>
<%
request.setCharacterEncoding("euc-kr");
%>
노래
<%
//문자열 배열로 받아서 반복하여 출력할것..
//★ 다중선택형 입력양식요소의 경우 선택하지 않은 요소는 값으로 넘어오지 않지만,
//아래와 같이 이름이 같은 단순텍스트상자의 경우 기입하지 않은 입력양식요소의 값도
//빈문자열로 전달된다.
String[] sings =request.getParameterValues("sing");
for(int i=0;i<sings.length;i++)
{
 out.println(sings[i]+", ");
}

out.println("갯수 : "+sings.length);
%>
</body>
</html>

Posted by 말없제이
,

<%@ 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>
<body>
<form action="Intro05pro.jsp" method="post">
직업 <select name="job">
<option value="A">군인</option>
<option value="B">회사원</option>
<option value="C">프로그래머</option>
<option value="D">디자이너</option>
</select>
취미 <input type="radio"  name="hobby" value="1">낚시
<input type="radio"  name="hobby" value="2">독서
<input type="radio"  name="hobby" value="3">음악

관심분야
<input type="checkbox"  name="interest" value="1">패션
<input type="checkbox"  name="interest" value="2">음악
<input type="checkbox"  name="interest" value="3">게임
<p>
종아하는 음식 :
<select name="food" multiple="multiple" size="5">
<option value="1">자장면</option>
<option value="2">햄버거</option>
<option value="3">떡라면</option>
</select>
<input type="submit" value="확인">
</form>
</body>
</html>



************  Intro05pro.jsp  ***************
<%@ 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>
<body>
<%
//JSP(Java Server Page) : 자바언어로 된 홈페이지 제작프로그래밍 언어(컴파일러)로
//서버에서 서블릿으로 변환되어 class로 컴파일되어 사용자에게
//웹페이지형태로 출력을 담당한다.
//실행순서는 위에서 시작되어서 아래로 쭈욱 내려가는 구조임
// % %는 원하면 여러번 사용이 가능.
%>

선택한 직업<% out.println(request.getParameter("job")); %><p>
선택한 취미<% out.println(request.getParameter("hobby")); %><p>
<%
//다중선택 양식요소는 request의 getParameterValues메서드를 사용하여
//여러개를 선택한 값들을 받아야 한다.
//다중선택요소의 경우 선택한 요소들만 배열로 넘어온다.
String[] interest = request.getParameterValues("interest");

for(int i=0;i<interest.length;i++)
{
  out.println(interest[i]+", ");
}
out.println("<p>갯수 : "+interest.length);
%>
관심분야 : <% out.println(request.getParameter("interest")); %><p>
<%
String[] foods = request.getParameterValues("food");
for(int i=0;i<foods.length;i++)
{
  out.println(foods[i]+", ");
}
out.println("<p>갯수 : "+foods.length);
%>
음식 : <% out.println(request.getParameter("food")); %><p>
</body>
</html>

Posted by 말없제이
,

package ch19;

import java.io.*;

public class Ch1908
{
 public static void main(String[] args) throws IOException
 {
  FileReader  in = new FileReader(new File("D:\\study\\java\\Project\\sample\\src\\ch19\\Ch1906.java"));
  int ch;
  StringBuffer stringBuffer = new StringBuffer();
  while((ch=in.read())!=-1)
  {
   stringBuffer.append((char)ch);
  }
  System.out.println(stringBuffer);
 
  FileWriter out = new FileWriter(new File("D:\\study\\java\\Project\\sample\\src\\ch19\\Output.java"));
  out.write(stringBuffer.toString());
  out.close();
 }
}

Posted by 말없제이
,

package ch19;

import java.io.*;

public class Ch1907
{
 public static void main(String[] args) throws IOException
 {
  //FileInputStream 클래스 : 텍스트화일 뿐만 아니라
  //바이너리화일까지 읽어들일 수 있다.
 
  FileInputStream in = new FileInputStream(new File("D:\\study\\java\\Project\\sample\\src\\ch19\\Ch1906.java"));
  int ch;
  //속도를 위해 StringBuilder 교체.
  //String result ="";
  StringBuilder result = new StringBuilder();
  while((ch=in.read())!=-1)
  {
   //속도를 위해 StringBuilder 교체.
   //result += (char)ch;
   result.append((char)ch);
  }
  in.close();
 
  System.out.println(result);
 
  FileOutputStream out = new FileOutputStream(new File("D:\\study\\java\\Project\\sample\\src\\ch19\\Output.java"));
  for(int i=0;i<result.length();i++)
  {
   ch=result.charAt(i);
   out.write(ch);
  }
  out.close();
 }
}

Posted by 말없제이
,

package ch19;

import java.io.*;

public class Ch1906
{
 public static void main(String[] args) throws IOException
 {
  //Reader시리즈 스트림클래스는 문자열처리에 적합
  InputStreamReader in = new InputStreamReader(System.in);
  int ch;
  String result="";
  while((ch=in.read())!= -1)
  {
   result +=(char)ch;  
  }
  System.out.println("result : "+result);
 
  OutputStreamWriter out = new OutputStreamWriter(System.out);
  out.write(result);
  out.close();
 }
}

Posted by 말없제이
,

package ch19;
//입출력스트림클래스 사용시 임포트할 패키지.
import java.io.*;

public class Ch1905
{

 public static void main(String[] args) throws IOException
 {
  //Stream이란 : 데이터와 데이터가 이동되는 연결되는 통로.
 
  //InputStream 클래스 : 입력스트리림중 가장 상위클래스이며
  //추상클래스 이므로 개체의 직접 생성이 불가능
 
  //Stream으로 시작되는 클래스는 바이너리데이터를 다루는데 유리
  //read() : 입력스트림에서 한글자를 읽어옴.
  //InputStream은 한글은 깨짐.
  InputStream in = System.in;
  int ch;
 
  String result="";
  //Ctrl-Z 누를때까지 무한반복한다.
  while((ch=in.read())!=-1)
  {
   result += (char)ch;
  }
 
  System.out.print("Result : "+result);
  in.close();
   
  // close없을경우 문제 발생 가능성있는 3가지.
  //1. 입출력 스트림
  //2. DB : webapplication
  //3. 통신
 
  //OutputStream : 출력스트림중 최상위 클래스로 추상 클래스
 
  //문자열 result를 콘솔출력에 내보내는 역활
  OutputStream out = System.out;
  for(int i=0;i<result.length();i++)
  {
   ch = result.charAt(i);
   out.write(ch);
   //용도를 알아보자꾸나. flush
   //out.flush();
  }
  //out.close();
 }
}

Posted by 말없제이
,

계정은 scott/tiger

1. xx번 부서는 ~~~ ->출력. concat 사용.
select concat(deptno, '번 부서는' || dname)
from dept;

2. 커미션이 확정된 사원의 사원번호,사원명,급여, 커미션 조회
select empno, ename, sal, comm
from emp
where comm is not null

3. 2번결과내 급여가 1500 이상인 사원번호,사원명,급여,커미션 조회
select empno, ename, sal, comm
from emp
where comm is not null and sal >= 1500

4. 3번결과를 급여 오름차순 조회.
select empno, ename, sal, comm
from emp
where comm is not null and sal >= 1500
order by sal asc

5.10번또는 20번 부서에 근무하는 사원들의
부서번호,사원명,급여,커미션,bonus를 bonus 오름차순, 동일보너스내 사원명 오름차순
bonus=기본 커미션+300. 커미션이 null이면 50을 기본커미션으로 함.
select empno, ename, sal, comm, (nvl(comm, 50)+300)as bonus
from emp
where deptno in (10, 20)
order by bonus asc, ename

Posted by 말없제이
,