리그캣의 개발놀이터

jsp 예제 소스코드 2 본문

프로그래밍 언어/jsp

jsp 예제 소스코드 2

리그캣 2018. 1. 25. 15:48

뇌를 자극하는 jsp 예제


7_3.html


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<HTML>
    <HEAD>
        <META http-equiv="Content-Type" content="text/html:charset=euc-kr">
        <TITLE>아이 러브 펫</TITLE>
    </HEAD>
    <BODY>
        <FORM ACTION=PetsResult.jsp>
        아이디:<INPUT TYPE=TEXT NAME=ID><BR><BR>
        다음 중 회원님이 키우고 있는 애완동물을 선택하십시오.<BR><BR>
            개<INPUT TYPE=CHECKBOX NAME=ANIMAL VALUE="개">
            고양이<INPUT TYPE=CHECKBOX NAME=ANIMAL VALUE="고양이">
            금붕어<INPUT TYPE=CHECKBOX NAME=ANIMAL VALUE="금붕어"><BR><BR>
        <INPUT TYPE=RESET VALUE="취소">
        <INPUT TYPE=SUBMIT VALUE="확인">
        </FORM>
    </BODY>
</HTML>
cs


7_4.jsp


1
2
3
4
5
6
7
8
9
10
11
12
<%@page contentType="text/html; charset=euc-kr"%>
<HTML>
    <HEAD>
        <TITLE>아이 러브 펫</TITLE>
    </HEAD>
    <BODY>
        아이디:${param.ID}<BR>
        선택한 동물: ${paramValues.ANIMAL{0}}
                ${paramValues.ANIMAL{1}}
                ${paramValues.ANIMAL{2}}            
    </BODY>
</HTML>
cs


7_5.jsp


1
2
3
4
5
6
7
8
9
10
11
12
13
<%@page contentType="text/html; charset=euc-kr"%>
<%
    Cookie cookie = new Cookie("NAME","John");
    response.addCookie(cookie);
%>
<HTML>
    <HEAD>
        <TITLE>쿠키 데이터 저장 프로그램</TITLE>
    </HEAD>
    <BODY>
        쿠키 값이 설정되었습니다.             
    </BODY>
</HTML>
cs


7_7.jsp


1
2
3
4
5
6
7
8
<%@page contentType="text/html;charset = euc-kr"%>
<HTML>
    <HEAD><TITLE>PageContext 내장 개체의 사용 예 </TITLE></HEAD>
    <BODY>
        요청 URL:${pageContext.request.requestURI}<BR>
    </BODY>
</HTML>
 
cs


7_8.jsp


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<%@page contentType="text/html;charset = euc-kr"%>
<HTML>
    <HEAD><TITLE>익스프레션 언어 연산자 연습 </TITLE></HEAD>
    <BODY>
        X = ${param.NUM1},Y=${param.NUM2}<BR><BR>
        X+Y=${param.NUM1 + param.NUM2}<BR>
        X-Y=${param.NUM1 - param.NUM2}<BR>
        X*Y=${param.NUM1 * param.NUM2}<BR>
        X/Y=${param.NUM1 / param.NUM2}<BR>
        X%Y=${param.NUM1 % param.NUM2}<BR>
        X가 더 큽니까? ${param.NUM1 - param.NUM2 > 0}<BR>
        Y가 더 큽니까? ${param.NUM1 - param.NUM2 < 0}<BR><BR>
        X와 Y가 모두 양수입니까? ${(param.NUM1>0)&&(param.NUM2 > 0)}<BR><BR>
        X와 Y가 같습니까? ${param.NUM1 == param.NUM2? "예":"아니오"}<BR><BR>
    </BODY>
</HTML>
 
cs


7_9.jsp

1
2
3
4
5
6
7
8
9
10
11
<%@page contentType="text/html;charset = euc-kr"%>
<HTML>
    <HEAD><TITLE>익스프레션 언어 연산자 연습 </TITLE></HEAD>
    <BODY>
        ${param.NUM1}을 ${param.NUM2}로 나눈 몫은? ${param.NUM1 div param.NUM2}<BR>
        나머지는?${param.NUM1 mod param.NUM2}<BR><BR>
        둘다 양수입니까?${(param.NUM1 gt 0)and(param.NUM2gt0)}<BR>
        둘다 음수입니까?${(param.NUM1 lt 0)and(param.NUM2lt0)}<BR>
    </BODY>
</HTML>
 
cs


7_10.jsp


1
2
3
4
5
6
7
8
9
10
<%@page contentType="text/html;charset = euc-kr"%>
<HTML>
    <HEAD><TITLE>문자열 비교</TITLE></HEAD>
    <BODY>
        입력 문자열:${param.STR1},${param.STR2}<BR><BR>
        두 문자열이 같습니까?${param.STR1 == param.STR2}<BR>
        어느 분자열이 먼저입니까?${param.STR1<param.STR2?param.STR1:param.STR2}
    </BODY>
</HTML>
 
cs


7_11.jsp


1
2
3
4
5
6
7
8
<%@page contentType="text/html;charset = euc-kr"%>
<HTML>
    <HEAD><TITLE>엠프티 연산자</TITLE></HEAD>
    <BODY>
        안녕하세요, ${empty param.ID?"guest":param.ID}님
    </BODY>
</HTML>
 
cs


7_12.jsp


1
2
3
4
5
6
7
8
9
10
<%@page contentType="text/html;charset = euc-kr"%>
<%
    String winners[] = new String[3];
    winners[0= "이수현" ;
    winners[1= "정세훈" ;
    winners[2= "김진희" ;
    request.setAttribute("WINNERS",winners);
    RequestDispatcher dispatcher = request.getRequestDispatcher("WinnersView.jsp");
    dispatcher.forward(request,response);
%>
cs


7_13.jsp


1
2
3
4
5
6
7
8
9
10
11
<%@page contentType="text/html;charset = euc-kr"%>
<%@page import="java.util.*"%>
<%
    ArrayList<String> items = new ArrayList<String>();
    items.add("딸기");
    items.add("오렌지");
    items.add("복숭아");
    request.setAttribute("FRUITS",items);
    RequestDispatcher dispatcher = request.getRequestDispatcher("FruitsView.jsp");
    dispatcher.forward(request,response);
%>
cs


7.14.jsp


1
2
3
4
5
6
7
8
9
10
11
<%@page contentType="text/html;charset = euc-kr"%>
<%@page import="java.util.*"%>
<%
    ArrayList<String> items = new ArrayList<String>();
    items.add("딸기");
    items.add("오렌지");
    items.add("복숭아");
    request.setAttribute("FRUITS",items);
    RequestDispatcher dispatcher = request.getRequestDispatcher("FruitsView.jsp");
    dispatcher.forward(request,response);
%>
cs


7_15.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package mall;
 
public class ProductInfo{
    private String name;
    private int value;
    public ProductInfo(){
    }
    public void setName(String name){
        this.name = name;
    }
    public String getName(){
        return name;
    }
    public void setPrice(int price){
        value=price;
    }
    public int getPrice(){
        return value;
    }
}
cs


7_16.jsp


1
2
3
4
5
6
7
8
9
10
<%@page contentType="text/html;charset=euc-kr"%>
<%@page import="mall.ProductInfo"%>
<%
    ProductInfo product = new ProductInfo();
    product.setName("초코케이크3호");
    product.setPrice(20000);
    request.setAttribute("PRODUCT",product);
    RequestDispatcher dispatcher = request.getRequestDispatcher("ProductInfoView.jsp");
    dispatcher.forward(request,response);
%>
cs


'프로그래밍 언어 > jsp' 카테고리의 다른 글

jsp 예제 소스 5  (0) 2018.01.25
jsp 예제 소스 4  (0) 2018.01.25
jsp 예제 소스 3  (0) 2018.01.25
jsp 예제 소스코드 - 1  (0) 2018.01.25
Comments