[JSP] ch03-02. Request

2017. 11. 13. 14:57·WEB/JSP
728x90
반응형

3-2. Request

requestParamin.html

<!DOCTYPE html>
<html lang="ko">
<head>
<title>requestParam</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
</head>
<body>
    <h2>설문 조사</h2>
    <form action="requestParamOut.jsp" method="post">
        <table>
            <tr>
                <th>이름</th>
                <td><input type="text" name="userName" size="10"/></td>
            </tr>
            <tr>
                <th>성별</th>
                <td>
                    <input type="radio" name="gender" value="male" checked>남
                    <input type="radio" name="gender" value="female">여
                </td>
            </tr>
            <tr>
                <th>좋은 계절
                <td>
                    <input type="checkbox" name="season" value="봄">봄
                    <input type="checkbox" name="season" value="여름">여름
                    <input type="checkbox" name="season" value="가을">가을
                    <input type="checkbox" name="season" value="겨울">겨울
                </td>
            </tr>
            <tr>
                <th>직업</th>
                <td>
                    <select name="job">
                        <option>회사원</option>
                        <option>자영업</option>
                        <option>학생</option>
                    </select>
                </td>
            </tr>
        </table>
        <input type="submit"/>
    </form>
</body>
</html>

 

requestParamOut.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<% 
    request.setCharacterEncoding("utf-8");
    String userName = request.getParameter("userName");
    String gender = request.getParameter("gender");
    String[] seasons = request.getParameterValues("season");
    String job = request.getParameter("job");
%>
답변 확인
<table>
    <tr>
        <th>이름</th>
        <td><%=userName%></td>
    </tr>
    <tr>
        <th>성별</th>
        <td>
            <%
                if(gender.equals("male")) gender="남";
                else gender="여";
           %><%=gender%>
        </td>
    </tr>
    <tr>
        <th>좋은 계절</th>
        <td>
            <%
             for(String season:seasons) out.print(season+" ");
           %>
        </td>
        <th>직업</th>
        <td><%=job%></td>
    </tr>
</table>
 
 
requestMethod.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<ul>
    <li>getContextPath(): <%=request.getContextPath()%></li>
    <li>getMethod(): <%=request.getMethod()%></li>
    <li>getRequestURL(): <%=request.getRequestURL()%></li>
    <li>getRequestURI(): <%=request.getRequestURI()%></li>
    <li>getQueryString(): <%=request.getQueryString()%></li>
    <li>getServerName(): <%=request.getServerName()%></li>
    <li>getProtocol(): <%=request.getProtocol()%></li>
</ul>

 

 

728x90
반응형

'WEB > JSP' 카테고리의 다른 글

[JSP] ch03-05. Forward Login  (0) 2017.11.13
[JSP] ch03-04. Redirect Login  (0) 2017.11.13
[JSP] ch03-01. FOR문  (0) 2017.11.13
[JSP] ch02-08. Include2  (0) 2017.11.13
[JSP] ch02-07. Include  (0) 2017.11.13
'WEB/JSP' 카테고리의 다른 글
  • [JSP] ch03-05. Forward Login
  • [JSP] ch03-04. Redirect Login
  • [JSP] ch03-01. FOR문
  • [JSP] ch02-08. Include2
밍글링글링
밍글링글링
mingling - 밍글링, 밍글밍글링. 코드와 어우러지다. IT/ 프로그래밍/소스
    반응형
    250x250
  • 밍글링글링
    mingling
    밍글링글링
  • 전체
    오늘
    어제
    • 밍글링글링 (407) N
      • Flutter (2)
      • 일상생활 (8)
        • 리뷰 (1)
        • 생활정보 (4)
        • 맛집 (0)
        • 여행 (0)
        • 모든정보 (3)
      • JAVA (126)
        • 개념 (6)
        • 예제 (115)
        • Exception (2)
      • C (1)
        • C (1)
        • C++ (0)
        • C# (0)
      • JS (29)
        • JavaScript (18)
        • JQuery (5)
        • AJax (0)
        • NODE.JS (6)
        • Angular.JS 2.0 (0)
      • WEB (87)
        • HTML (6)
        • CSS (61)
        • JSP (20)
        • JSTL (0)
      • FrameWork (8)
        • Spring (8)
        • BootStrap (0)
        • MyBATIS (0)
        • JUnit (0)
      • 외부 라이브러리 (5)
      • 공유 소스 관리 (5)
        • Git (5)
        • SVN (0)
      • 빅데이터 프로그래밍 (37)
        • Python (37)
        • R Programming (0)
      • DB (7)
        • ORACLE (0)
        • MySql (6)
      • Development Tools (7)
        • StarUML (0)
        • eXERD (0)
        • Eclipse (4)
      • SKILL (6)
        • Migration (0)
        • Security (6)
      • MicroSoft (0)
        • Excel (0)
        • Word (0)
      • Android (0)
      • Server (21)
        • Ubuntu (5)
        • Linux (15)
      • IOS (0)
      • XML (0)
      • 미디어 (0)
      • 공지사항 (3)
      • NETWORK (1)
      • 게임 (4)
        • 피파 (1)
        • 리니지M (0)
        • 배틀그라운드 (1)
        • 듀랑고 (2)
      • 세상 이슈 (6)
      • 일렉트론 (0)
      • 대회 소식 (4)
      • 업무 (2)
      • Express, Vue (6)
      • docker (11)
      • svelte (3)
      • 블록체인 (1)
      • IT (10) N
      • Rust (0)
  • 블로그 메뉴

    • 홈
    • 태그
    • 미디어로그
    • 위치로그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    css list
    nginx
    API 설계
    css table
    ssl 인증서 발급
    자바 생성자
    리눅스 설치
    css float
    VS Code 팁
    에디터 팁
    브라우저 자동화
    jsp parameter
    css perspective
    AI 코딩 에이전트
    자바 for문
    java casting
    vue 설치
    자바 객체 지향
    lang rust
    spring java
    nginx ssl 설정
    프런트엔드
    SSL 인증서
    svelte
    docker
    gitlab 설치
    css transition
    오류
    Node
    Java Array
    러스트
    클론코딩
    servlet class
    nginx ssl 적용
    자바 배열
    Rust lang
    자바 클래스
    vue cli
    css tb
    React Compiler
    css block
    vscode
    ubuntu
    rust linux
    mysql db
    자바 exception
    jsp include
    티스토리 자동화
    Extension Bisect
    proxy pass
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.6
밍글링글링
[JSP] ch03-02. Request
상단으로

티스토리툴바