태터데스크 관리자

도움말
닫기
적용하기   첫페이지 만들기

태터데스크 메시지

저장하였습니다.


http://docs.sun.com/app/docs/doc/819-3669/bnakc?l=en&q=jstl&a=view
top

Trackback Address :: http://www.ssial.com/trackback/164 관련글 쓰기

  1. Chanel Outlet 2011/09/17 21:21 댓글주소 | 수정/삭제 | 댓글

    Time is what you make of it.

  2. Burberry Bags 2011/10/13 16:50 댓글주소 | 수정/삭제 | 댓글

    I'm happy I found this blog! From time to time students want to cognitive the keys of productive literary essays composing. Your first-class knowledge about this good post can become a proper basis for such people. Thanks.

  3. Coach Outlet Online 2011/11/15 12:38 댓글주소 | 수정/삭제 | 댓글

    I'm happy I found this blog ! It's very good and thank you for sharing it !

  4. Coach Factory Online 2011/12/11 22:51 댓글주소 | 수정/삭제 | 댓글

    댓글주소 | 수정/삭제 | 댓글

  5. Coach Factory Outlet Online 2011/12/14 15:52 댓글주소 | 수정/삭제 | 댓글

    Great Coach Factory Outlet Online
    . A lot of useful information here. I’m sending it to some friends!

  6. Burberry Shop Online 2012/01/11 15:22 댓글주소 | 수정/삭제 | 댓글

    <p><strong><a href="http://www.burberrydiscount.org/">Burberry Discount</a></strong> developed a local community utilizing bags to write about in her appreciation and consciousness and also to preserve people within your loop about high quality replica artist handbag sites, such as touch bags.<br>
    <a href="http://www.burberryoutletshoponline.com/"><strong>Burberry Shop Online</strong></a> puts inside the work to can be found throughout only the extremely perfect high quality sites, steering toward magnitude of placing her on the internet protection inside the collection by attempting to purchase a replica artist handbag by method of the website itself.<br>
    <a href="http://www.onlinesburberryoutlet.com/"><strong>Burberry Outlet</strong></a> then talks concerning the website on blog of handbags. Luckily, these various quality websites are acquiring shut affordable inside the droves to make certain that people aren't scammed away from their hard-earned money.</p>

  7. abercrombie and fitch deutschland 2012/02/07 16:56 댓글주소 | 수정/삭제 | 댓글

    Keep up the good work!.

  8. abercrombie 2012/02/07 16:56 댓글주소 | 수정/삭제 | 댓글

    This was very informative. I have been reading your blog a lot over the past few days and it has earned a place in my bookmarks.

Write a comment


jstl API

JSP/Basic 2008/11/27 09:16
http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/index.html
top

Trackback Address :: http://www.ssial.com/trackback/163 관련글 쓰기

  1. louis vuitton 2011/09/29 17:27 댓글주소 | 수정/삭제 | 댓글

    [url=http://www.my-coachoutletonline.com/]coach outlet store online[/url]
    [url=http://www.coachoutletonline-malls.com/]coach factory outlet[/url]
    [url=http://www.coachfactoryonline-outlets.com/]coach factory outlet online[/url]
    [url=http://www.cheapcoachbags-purses.com/]cheap coach bags[/url]
    [url=http://www.coachhandbags-outletonline.net/]coach outlet online[/url]
    [url=http://www.lvbags-louisvuitton.com/]lv bags[/url]
    [url=http://www.coachwallets-outlet.net/]coach wallet[/url]
    [url=http://www.louisvuitton9.net/]louis vuitton outlet[/url]
    [url=http://www.louisvuitton0.net/]louis vuitton[/url]
    [url=http://www.louisvuittonoutlet0.net/]louis vuitton outlet[/url]
    [url=http://www.coachfactoryonline-outlets.com/]coach factory outlet[/url]
    [url=http://www.outletcoachfactoryonline.com/]coach factory[/url]
    [url=http://www.topoutletmalls.net/]louis vuitton outlet[/url]
    [url=http://www.gogooutletonline.net/]louis vuitton outlet online[/url]

  2. Burberry Bags 2011/10/13 16:50 댓글주소 | 수정/삭제 | 댓글

    I'm happy I found this blog! From time to time students want to cognitive the keys of productive literary essays composing. Your first-class knowledge about this good post can become a proper basis for such people. Thanks.

  3. Coach Outlet Online 2011/11/15 12:23 댓글주소 | 수정/삭제 | 댓글

    It's very good!Thank you for sharing it!I like buying handbags of the internet website:http://www.mycoachoutletstoreonline.com

  4. Coach Factory Online 2011/12/11 23:00 댓글주소 | 수정/삭제 | 댓글

    I댓글주소 | 수정/삭제 | 댓글

  5. Coach Factory Outlet Online 2011/12/14 15:57 댓글주소 | 수정/삭제 | 댓글

    Great Coach Factory Outlet Online
    . A lot of useful information here. I’m sending it to some friends!

  6. Burberry Shop Online 2012/01/11 15:22 댓글주소 | 수정/삭제 | 댓글

    <p><strong><a href="http://www.burberrydiscount.org/">Burberry Discount</a></strong> developed a local community utilizing bags to write about in her appreciation and consciousness and also to preserve people within your loop about high quality replica artist handbag sites, such as touch bags.<br>
    <a href="http://www.burberryoutletshoponline.com/"><strong>Burberry Shop Online</strong></a> puts inside the work to can be found throughout only the extremely perfect high quality sites, steering toward magnitude of placing her on the internet protection inside the collection by attempting to purchase a replica artist handbag by method of the website itself.<br>
    <a href="http://www.onlinesburberryoutlet.com/"><strong>Burberry Outlet</strong></a> then talks concerning the website on blog of handbags. Luckily, these various quality websites are acquiring shut affordable inside the droves to make certain that people aren't scammed away from their hard-earned money.</p>

  7. abercrombie and fitch deutschland 2012/02/07 16:56 댓글주소 | 수정/삭제 | 댓글

    Keep up the good work!.

  8. abercrombie 2012/02/07 16:56 댓글주소 | 수정/삭제 | 댓글

    This was very informative. I have been reading your blog a lot over the past few days and it has earned a place in my bookmarks.

Write a comment


taglib download site

JSP/Basic 2008/11/25 11:17
http://jakarta.apache.org/site/downloads/downloads_taglibs.html

jstl.jar 와 standard.jar를 WEB-INF\lib에 복사한다.
jstl은 인터페이스이고 standard는 구현체이다.

http://java.sun.com/products/jsp/taglibraries/index.jsp
top

Trackback Address :: http://www.ssial.com/trackback/161 관련글 쓰기

  1. Chanel Outlet 2011/09/17 21:45 댓글주소 | 수정/삭제 | 댓글

    Time is what you make of it.

  2. louis vuitton 2011/09/29 17:27 댓글주소 | 수정/삭제 | 댓글

    <a href="http://www.my-coachoutletonline.com/" title="coach outlet store online">coach outlet store online</a>
    <a href="http://www.coachoutletonline-malls.com/" title="coach factory outlet">coach factory outlet</a>
    <a href="http://www.coachfactoryonline-outlets.com/" title="coach factory outlet online">coach factory outlet online</a>
    <a href="http://www.cheapcoachbags-purses.com/" title="cheap coach bags">cheap coach bags</a>
    <a href="http://www.coachhandbags-outletonline.net/" title="coach outlet online">coach outlet online</a>
    <a href="http://www.lvbags-louisvuitton.com/" title="lv bags">lv bags</a>
    <a href="http://www.coachwallets-outlet.net/" title="coach wallet">coach wallet</a>
    <a href="http://www.louisvuitton9.net/" title="louis vuitton outlet">louis vuitton outlet</a>
    <a href="http://www.louisvuitton0.net/" title="louis vuitton">louis vuitton</a>
    <a href="http://www.louisvuittonoutlet0.net/" title="louis vuitton outlet">louis vuitton outlet</a>
    <a href="http://www.coachfactoryonline-outlets.com/" title="coach factory outlet">coach factory outlet</a>
    <a href="http://www.outletcoachfactoryonline.com/" title="coach factory">coach factory</a>
    <a href="http://www.topoutletmalls.net/" title="louis vuitton outlet">louis vuitton outlet</a>
    <a href="http://www.gogooutletonline.net/" title="louis vuitton outlet online">louis vuitton outlet online</a>
    <a href="http://www.louisvuitton-outlet.ca/" title="louis vuitton outlet">louis vuitton outlet</a>
    <a href="http://www.coachoutletonline-max.com/" title="coach outlet online">coach outlet online</a>
    <a href="http://www.ca-coach.com/" title="coach outlet online">coach outlet online</a>

  3. Coach Outlet Online 2011/11/15 12:44 댓글주소 | 수정/삭제 | 댓글

    I'm happy I found this blog ! It's very good and thank you for sharing it !

  4. new era cap 2011/12/21 15:34 댓글주소 | 수정/삭제 | 댓글

    That was a reversal of <a href="http://www.wholesalenewerahatscaps.com/">new era caps</a> his sour bets earlier in the year that <a href="http://www.wholesalenewerahatscaps.com/">new era hat</a> Treasury yields would climb

  5. abercrombie and fitch deutschland 2012/02/07 16:56 댓글주소 | 수정/삭제 | 댓글

    Keep up the good work!.

  6. abercrombie 2012/02/07 16:56 댓글주소 | 수정/삭제 | 댓글

    This was very informative. I have been reading your blog a lot over the past few days and it has earned a place in my bookmarks.

Write a comment


=========================== PagingTest.jsp ==================================

<html>
<head><title>페이징   블록 처리 테스트</title>
<link href="style.css" rel="stylesheet" type="text/css">
<body>
 <center>
  <br>
  <br>
  <h2>페이징   블록 처리 테스트</h2>
  <FORM METHOD=POST ACTION="PagingResult.jsp">
   총 레코드 값 : <INPUT TYPE="text" NAME="totalRecord">&nbsp;
      <INPUT TYPE="submit" value="보내기">
  </FORM>
 </center>
</body>
</html>

=========================== PagingResult.jsp ==================================

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

 /*
  페이징에 필요한 변수 10가지
 
 // 초기값 변수 3개
 01. totalRecord  //전체 record 수 , 배열의 length, size(), length(), sql문의 count()
 02. NUM_PER_PAGE = 10; // 한 페이지에 보여질 행(목록)의 수 지정 , 상수
 03. PAGE_PER_BLOCK = 20; // 한 블록에서 보여질 페이지의 수 지정, 상수
 
 // 사용자 요청 변수 2개
 04. nowPage   //  디폴트 값은 1페이지(인덱스 값은 0), 사용자의 요청의 의해서 결정 ,
      //  request.getParameter("nowPage"); 으로 받아서 사용
      //  beginPerPage를 계산하는 데 사용하기 때문에 타입케스팅이 필요하다.
      //  Integer.parseInt(request.getParameter("nowPage"));
 05. nowBlock  //  디폴트 값은 1 블록(인덱스 값은 0), 사용자의 요청의 의해서 결정 ,
      // request.getParameter("nowBlock"); 으로 받아서 사용
      // 페이징의 페이지에 표시되는 숫자의 인덱스 값을 구하기 위해서 타입케스팅이 필요하다.
      //  Integer.parseInt(request.getParameter("nowBlock"));
 
 // 검색 처리 변수 2개
 06. keyField  // 검색기능을 수행 할 때 필요한 필드명를 저장하는 변수, sql문에서 사용
 07. keyWord   // 검색기능을 수행 할 때 필요한 필드의 검색하려는 내용을 저장하는 변수, sql문에서 사용
        // select * from board where " + keyField + " like '%" + keyWord + "%'
 
 // 페이징을 화면에 표시 할 때 필요한 변수 3개
 08. beginPerPage  // 페이지를 출력 할 때 첫번째 위치를 찾는 변수, for문의 초기값에 사용
                   // 계산하는 방법은  = (nowPage * NUM_PER_PAGE) + 1;
 09. totalPage   // 전체 페이지의 숫자를 저장해서 페이징의 페이지 숫자를 표시 할 때 필요,
          // 계산하는 방법은  = (totalREecord / NUM_PER_PAGE) + (((totalRecord % NUM_PER_PAGE) != 0) ? 1 : 0);
          // 계산하는 방법은  = (int)Math.ceil((double)totalRecord / NUM_PER_PAGE);
 10. totalBlock  // 전체 블록수를 저장해서 페이징의 블록 숫자를 표시 할 때 필요,
     // 계산하는 방법은  = (totalPage / NUM_PER_BLOCK) + (((totalRecord % NUM_PER_BLOCK) != 0) ? 1 : 0);
      // 계산하는 방법은  = (int)Math.ceil((double)totalPage / NUM_PER_BLOCK);
 */
 
    int nowPage = 0;
    int nowBlock = 0;
    int totalRecord = Integer.parseInt(request.getParameter("totalRecord"));
    int NUM_PER_PAGE = 7;          
    int PAGE_PER_BLOCK = 10;   
   
 int totalPage =(int)Math.ceil((double)totalRecord / NUM_PER_PAGE);
 int totalBlock =(int)Math.ceil((double)totalPage / PAGE_PER_BLOCK);
 
 if (request.getParameter("nowPage") != null){
   nowPage= Integer.parseInt(request.getParameter("nowPage")); }
 if (request.getParameter("nowBlock") != null){
   nowBlock = Integer.parseInt(request.getParameter("nowBlock"));}
 int beginPerPage =   nowPage * NUM_PER_PAGE; 
%>
<html>
<head><title>JSPBoard</title>
<link href="style.css" rel="stylesheet" type="text/css">
<script>
function preBlock(nowBlock,nowPage){
      document.total.nowBlock.value = nowBlock;
   document.total.nowPage.value = nowPage;
      total.submit();
 }

function prePage(nowBlock,nowPage){
      document.total.nowBlock.value = nowBlock;
   document.total.nowPage.value = nowPage;
      total.submit();
 }

function afterBlock(nowBlock,nowPage){
      document.total.nowBlock.value = nowBlock;
   document.total.nowPage.value = nowPage;
      total.submit();
 }
</script>
</head>
<body><center><br>
 <h2>페이징  블록 처리 테스트</h2>
 <br>
  <table>
   <tr>
   <td>게시물번호 : &nbsp;</td>
   </tr>
  
 <%
 for (int i = beginPerPage;i < (beginPerPage+NUM_PER_PAGE); i++) {
  if (i==totalRecord){ break;}
 %>
 <tr>
 <td align=center><%= i + 1  %>&nbsp;</td>
 </tr>
 <%}%>
 </table><p>
 <table>
  <tr>
   <td align="left" >
 <% if(totalRecord !=0){ %> Go to Page
 <% if (nowBlock > 0) {%>
 <a href="javascript:preBlock('<%=nowBlock - 1 %>','<%=((nowBlock - 1) * PAGE_PER_BLOCK)%>')">
 이전 <%=PAGE_PER_BLOCK %>개</a>
 <%}%>

 :::

 <%
    for (int i = 0; i < PAGE_PER_BLOCK; i++) { %>
    <a href="javascript:prePage('<%=nowBlock%>','<%=(nowBlock*PAGE_PER_BLOCK) + i %>')">
 <%=(nowBlock * PAGE_PER_BLOCK) + i + 1 %></a>
    <% if ((nowBlock * PAGE_PER_BLOCK) + i + 1 == totalPage) { break; } %>
 <%} %>

 :::

 <% if (totalBlock > nowBlock + 1) { %>
 <a href="javascript:afterBlock('<%=nowBlock + 1 %>','<%=((nowBlock +1) * PAGE_PER_BLOCK)%>')">
 다음 <%=PAGE_PER_BLOCK%>개</a>
 <%}%>

 <%} else{out.println("등록된 게시물이 없습니다."); }%>
    </td>
   </tr>
  </table>
  <form name="total">
   <input type="hidden" name ="totalRecord" value="<%=totalRecord%>">
   <input type="hidden" name ="nowBlock">
   <input type="hidden" name ="nowPage">
  </form>
  </center>
 </body>
</html>

top

Trackback Address :: http://www.ssial.com/trackback/149 관련글 쓰기

  1. asd 2011/11/13 21:47 댓글주소 | 수정/삭제 | 댓글

    asd

  2. abercrombie and fitch deutschland 2012/02/07 16:56 댓글주소 | 수정/삭제 | 댓글

    Keep up the good work!.

  3. abercrombie 2012/02/07 16:56 댓글주소 | 수정/삭제 | 댓글

    This was very informative. I have been reading your blog a lot over the past few days and it has earned a place in my bookmarks.

Write a comment


Container를 이용해서 pool객체를 이용하기 위해서는 JNDI를 이용해야 한다.
JNDI는 J2EE의 javax.naming.* 패키지안의 JNDI 클래스를 import해야한다.

==============   데이터를 처리하는 JDBC 로직을 수행하는 파일  ==============

<%@ page import="javax.sql.*"%>
<%@ page import="javax.naming.*"%>

<%
.
.
.
 Context initCtx = new InitialContext();
 Context envCtx = (Context)initCtx.lookup("java:comp/env");
 DataSource ds = (DataSource)envCtx.lookup("jdbc/MySQLDataSource");
 con = ds.getConnection();
.
.
.
%>


그리고 프로젝트 WEB-INF\web.xml과 %CATALINA_HOME%\conf\server.xml 을 수정해야 한다.
================ web.xml ============================
<resource-ref>element를 추가한다.
=====================================================

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">

.
.
.

  <resource-ref>
   <res-ref-name>jdbc/MySQLDataSource</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
   <res-auth>Container</res-auth>
  </resource-ref>
.
.
.
</web-app>

================ server.xml ============================
<Resource>element를 두 곳에 추가한다.
=======================================================

<Server port="8005" shutdown="SHUTDOWN">
.
.
.
  <GlobalNamingResources>
       <Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>


      <Resource auth="Container" name="jdbc/MySQLDataSource" type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver" password="1234" maxIdle="2" maxWait="5000" username="jspuser"
   url="jdbc:mysql://localhost:3306/testboarddb"
   maxActive="4"/>

  </GlobalNamingResources>
.
.
.
  <Service name="Catalina">
.
.
.
    <Engine defaultHost="localhost" name="Catalina">
.
.
.
        <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">
.
.
.
           <Context docBase="TestBoard" path="/TestBoard" reloadable="true" source="org.eclipse.jst.jee.server:TtestBoard">

              <Resource auth="Container" name="jdbc/MySQLDataSource" type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver" password="1234" maxIdle="2" maxWait="5000" username="jspuser"
   url="jdbc:mysql://localhost:3306/testboarddb"
   maxActive="4"/>

           </Context>

       </Host>
    </Engine>
  </Service>
</Server>
top

Trackback Address :: http://www.ssial.com/trackback/139 관련글 쓰기

  1. Chanel Outlet 2011/09/17 21:30 댓글주소 | 수정/삭제 | 댓글

    Time is what you make of it.

  2. Burberry Bags 2011/10/13 17:11 댓글주소 | 수정/삭제 | 댓글

    I'm happy I found this blog! From time to time students want to cognitive the keys of productive literary essays composing. Your first-class knowledge about this good post can become a proper basis for such people. Thanks.

  3. Coach Outlet Online 2011/11/15 12:24 댓글주소 | 수정/삭제 | 댓글

    It's very good!Thank you for sharing it!I like buying handbags of the internet website:http://www.mycoachoutletstoreonline.com

  4. Coach Factory Online 2011/12/11 23:00 댓글주소 | 수정/삭제 | 댓글

    댓글주소 | 수정/삭제 | 댓글

  5. Coach Factory Outlet Online 2011/12/14 15:58 댓글주소 | 수정/삭제 | 댓글

    Great Coach Factory Outlet Online
    . A lot of useful information here. I’m sending it to some friends!

  6. abercrombie and fitch deutschland 2012/02/07 16:56 댓글주소 | 수정/삭제 | 댓글

    Keep up the good work!.

  7. abercrombie 2012/02/07 16:56 댓글주소 | 수정/삭제 | 댓글

    This was very informative. I have been reading your blog a lot over the past few days and it has earned a place in my bookmarks.

Write a comment


snaq.db.ConnectionPoolManager : DBPool객체를 해당 프로젝트의 WEB-INF\lib폴더에 복사해 놓는다.
다운로드 :




===================== ConnectionManager.java  ======================
//Pool객체를 생성해주는 역할을 수행하는 Factory 디자인 패턴을 적용시켰다.

package test.db;

import java.sql.Connection;
import java.sql.SQLException;

import snaq.db.ConnectionPoolManager;

/**
 * Connection Pooling의 Connection 객체를 관리하는 클래스.
 */
public class ConnectionManager {
 
 /**
  * Connection 객체를 반환하는 메써드.
  * @return
  * @throws SQLException
  */
 public static Connection getConnection() throws SQLException {
  ConnectionPoolManager cpm = ConnectionPoolManager.getInstance();
 
  return cpm.getConnection("mysql");
 
 }
}


========================  dbpool.properties  ============================
# 데이타베이스의 정보를 갖고 있다.
# ConnectionPoolManager 객체가 데이타베이스에 접속할 때 필요하다.
# 프로젝트 폴더의 src 폴더에 생성한다.
# 이클립스에서 컴파일 되어지면 WEB-INF\classes폴더에 복사되어진다.

#JDBC Driver 등록한다.
drivers=com.mysql.jdbc.Driver

#사용할 데이터베이스의 URL
mysql.url=jdbc:mysql://localhost:3306/testboarddb

#사용할 데이터베이스의 사용자 아이디
mysql.user=jspuser

#사용할 데이터베이스의 비밀번호
mysql.password=1234

#초기 Connection pooling 사이즈를 입력한다.
mysql.initsize=5

#Connection pooling 최대 사이즈를 입력한다.
mysql.maxpool=10


==============   데이터를 처리하는 JDBC 로직을 수행하는 파일  ==============


<%@ page import="test.db.ConnectionManager" %>

<%
.
.
con = ConnectionManager.getConnection();
.
.
%>

top

Trackback Address :: http://www.ssial.com/trackback/138 관련글 쓰기

  1. Chanel Outlet 2011/09/17 21:22 댓글주소 | 수정/삭제 | 댓글

    Time is what you make of it.

  2. Burberry Bags 2011/10/13 16:51 댓글주소 | 수정/삭제 | 댓글

    I'm happy I found this blog! From time to time students want to cognitive the keys of productive literary essays composing. Your first-class knowledge about this good post can become a proper basis for such people. Thanks.

  3. Coach Outlet Online 2011/11/15 12:39 댓글주소 | 수정/삭제 | 댓글

    I'm happy I found this blog ! It's very good and thank you for sharing it !

Write a comment


DBCP 기본사용법

JSP/Basic 2008/11/07 16:39


사용하는 데이타베이스에 해당하는 JDBC 드라이버를 WEB-INF\lib폴더에 복사해 놓는다.

<%
//1. 드라이버를 찾는다
 Class.forName("com.mysql.jdbc.Driver");

 //2. 데이타베이스에 아이디와 패스워드 그리고 데이타베이스의 변형인 JDBC URL을 통해서 연결한다.
 con = DriverManager.getConnection( "jdbc:mysql://localhost:3306/testboarddb", spuser", "1234");

%>

top

Trackback Address :: http://www.ssial.com/trackback/137 관련글 쓰기

  1. Chanel Outlet 2011/09/17 21:37 댓글주소 | 수정/삭제 | 댓글

    Time is what you make of it.

  2. Burberry Bags 2011/10/13 17:39 댓글주소 | 수정/삭제 | 댓글

    I'm happy I found this blog! From time to time students want to cognitive the keys of productive literary essays composing. Your first-class knowledge about this good post can become a proper basis for such people. Thanks.

  3. Coach Outlet Online 2011/11/15 12:45 댓글주소 | 수정/삭제 | 댓글

    I'm happy I found this blog ! It's very good and thank you for sharing it !

Write a comment



1. HTTP의 POST메소드 전송(요청):  요청을 페이지마다 내장객체 request를 이용해서 한글처리한다.
 이때 request.getParameter()메소드 또는 액션태그의 setProperty 태그 보다는 앞에서 처리해야 한다.

<% request.setCharacterEncoding("EUC-KR"); %>
<%
     request.getParameter("name");
     .
     .
     .
%>
<jsp:useBean id="boardBean" class="test.BoardBean">
 <jsp:setProperty name="boardBean" property="*" />
</jsp:useBean>

2.  HTTP의 POST메소드 전송(요청):  web.xml파일에 filter element로 추가해서 모든 페이지에서 개별적으로 한글 처리 하지 않고 사용할 수 있다.

<filter>element와  <filter-mapping>element를 추가한다.

엘레먼트의 순서는다음과 같다.
Content Model : (((description*, display-name*, icon*)) | distributable | context-param | filter | filter- mapping | listener | servlet | servlet-mapping | session-config | mime-mapping | welcome-file-list |  error-page | jsp-config | security-constraint | login-config | security-role | ((env-entry*, ejb-ref*, ejb-local-ref*, ((service-ref*)), resource-ref*, resource-env-ref*, message-destination-ref*, persistence- context-ref*, persistence-unit-ref*, post-construct*, pre-destroy*)) | message-destination | locale-encoding-mapping-list)*


  <filter>
   <filter-name>encoding_euckr</filter-name>
   <filter-class>test.filters.SetCharacterEncodingFilter</filter-class>
   <init-param>
    <param-name>encoding</param-name>
    <param-value>euc-kr</param-value>
   </init-param>
  </filter>
 
  <filter-mapping>
   <filter-name>encoding_euckr</filter-name>
   <url-pattern>/*</url-pattern>
  </filter-mapping>


이때 사용하는 SetCharacterEncodingFilter.java 파일은 인스톨 버전으로 톰캣을 설치할때 옵션으로 example을 설치했다면 
%CATALINA_HOME%\webapps\examples\WEB-INF\classes\filters폴더안에 있다.
binary버전으로 설치한 경우에는 위의 폴더가 항상 있다.



3.  HTTP의 GET메소드 전송(요청): HTTP의 GET전송 방식은 binary방식이 아니고 queryString방식이기 때문에 필터에 의한 방식에 parameter를 제대로 전송할 수 없다.
이유는 queryString은 URI에 추가적으로 덧붙여져서 전송되는 방식이어서 변수처리되기 이전에 전송되어지기 때문이다.
위에서 사용한   SetCharacterEncodingFilter.java 파일은 parameter를 받기 이전에encoding이라는 변수를 사용해서 한글처리를 하는 것인데 URI 주소값은 그 이전 시점에 동작하기 때문이다.

해결방법 : server.xml의 <Server>   ->  <Service>  ->  <Connector> element에 다음의 내용을 추가해주면 HTTP의 GET방식에서도 한글 처리가 된다.

<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"  URIEncoding="euc-kr"/>

주의: <Connector> element가 두개 있으므로 잘 보고 자신이 사용하고 있는 HTTP 서비스 포트에 해당하는 Connector에 추가한다.
top

Trackback Address :: http://www.ssial.com/trackback/136 관련글 쓰기

Write a comment



public class BoardBean
{
     private int num;  // 자동부여
     private String writer; //사용자입력
     private String email; //사용자입력
     private String subject; //사용자입력
     private String passwd; //사용자입력
     private String content; //사용자입력

     private Timestamp regDate; //자동부여  OR 생성
/*
    // 자동부여
     private String regDate;
*/
     private String ip; // 요청 -> 생성
     private int readCount ; // 요청 -> 생성

     private int pos; //생성
     private int depth; //생성
/* 
     // 답글 생성시 그룹을 이용한 방법
     private int ref;
     private int reStep;
     private int reLevel;
*/



.
.
생략  setter메소드/getter메소드들 11개 또는 12개
.
.
.
}
======================== writeForm.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>
<%
int num=0,depth=0,pos=0;
%>
<center>글쓰기</center>

<br>
<form method="post" name="writeform" action="writeResult.jsp">
<input type="hidden" name="num" value="<%=num%>">
<input type="hidden" name="depth" value="<%=depth%>">
<input type="hidden" name="pos" value="<%=pos%>">
<table width="400" border="1" cellspacing="0" cellpadding="0" align="center">
<tr>
 <td align="right" colspan="2">
  <a href="list.jsp">글목록</a>
 </td>
</tr>
<tr>
 <td width="70" align="center">이름</td>
 <td width="330">
  <input type="text" name="writer" size="10" maxlength="10">
 </td>
</tr>
<tr>
 <td width="70" align="center">제목</td>
 <td width="330">
  <input type="text" name="subject" size="10" maxlength="10">
 </td>
</tr>
<tr>
 <td width="70" align="center">이메일</td>
 <td width="330">
  <input type="text" name="email" size="10" maxlength="10">
 </td>
</tr>
<tr>
 <td width="70" align="center">내용</td>
 <td width="330">
  <textarea rows="13" cols="40" name="content"></textarea>
 </td>
</tr>
<tr>
 <td width="70" align="center">비밀번호</td>
 <td width="330">
  <input type="password" name="passwd" size="10" maxlength="10">
 </td>
</tr>
<tr>
 <td align="right" colspan="2">
  <input type="submit" value="글쓰기">
  <input type="reset" value="다시작성">
 </td>
</tr>
</table>
</form>
</body>
</html>

======================== writeResult.jsp =========================

<%@ page language="java" contentType="text/html; charset=EUC-KR"
 pageEncoding="EUC-KR"%>
<%@ page import="java.util.Vector"%>
<%@ page import="java.sql.*" %>
<%@ page import="testjdbc.BoardBean"%>
<%@ page import="java.util.Enumeration" %>
<%@ page import="java.util.Iterator" %>


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


<%@page import="java.util.Enumeration"%><jsp:useBean id="boardBean" class="testjdbc.BoardBean" scope="request" />
<jsp:setProperty name="boardBean" property="*" />

<%
 boardBean.setRegDate(new Timestamp(System.currentTimeMillis()));
 boardBean.setIp(request.getRemoteAddr());
 System.out.println("여기까지 오나!000");
 Connection con = null;
 Statement stmt = null;
 PreparedStatement pstmt = null;
 ResultSet rs = null;
 Vector<BoardBean> list = new Vector<BoardBean>();

  //1. 드라이버를 찾는다
  Class.forName("com.mysql.jdbc.Driver");
  System.out.println("여기까지 오나!001");
  //2. 데이타베이스에 아이디와 패스워드 그리고 데이타베이스의 변형인URL을 통해서 연결한다.
  con = DriverManager.getConnection(
    "jdbc:mysql://localhost:3306/test", "abc", "1234");
  try {
  System.out.println("여기까지 오나!002");
  // 1,2번 까지는 인스턴스가 필요없지만 3번에서부터는 인스턴스(객체)가 필요하다.
  // DriverManager 클래스가 리턴해준다.

  //3. sql문장을 만들 준비를 한다.
  stmt = con.createStatement();
  System.out.println("여기까지 오나!003");
  //4. sql문장을 실행 시킨다.
  String sql = "insert into board(num,writer,email,subject,passwd,reg_date,read_count,depth,pos,content,ip) values(" + boardBean.getNum()
    + ",'" + boardBean.getWriter() + "','"
    + boardBean.getEmail() + "','" + boardBean.getSubject()
    + "','" + boardBean.getPasswd() + "','"
    + boardBean.getRegDate() + "',0,"
    + boardBean.getDepth() + "," + boardBean.getPos()
    + ",'" + boardBean.getContent() + "','"
    + boardBean.getIp() + "')";
  stmt.executeUpdate(sql);

   System.out.println("여기까지 오나!004");
  /*
   //3,4번을 PreparedStatement를 이용해서 다음과 같이 바꾸어 쓸수 있다.
   String sql = "insert into board(writer,email,subject,passwd,reg_date,read_count,depth,pos,content,ip) values(?,?,?,?,?,0,?,?,?,?)";
   pstmt = con.prepareStatement(sql);
   //pstmt.setInt(1,boardBean.getNum());
   pstmt.setString(1,boardBean.getWriter());
   pstmt.setString(2,boardBean.getEmail());
   pstmt.setString(3,boardBean.getSubject());
   pstmt.setString(4,boardBean.getPasswd());
   pstmt.setTimestamp(5,boardBean.getRegDate());
   //pstmt.setInt(6,boardBean.getReadCount()); // read_count 필드는 직접 입력한다. 값: 0
   pstmt.setInt(6,boardBean.getDepth());
   pstmt.setInt(7,boardBean.getPos());
   pstmt.setString(8,boardBean.getContent());
   pstmt.setString(9,boardBean.getIp());
   System.out.println("여기까지 오나!005");
   pstmt.executeUpdate();
   System.out.println("여기까지 오나!006");
   */
  // 입력작업 완료 이후에 다시 4번부터 다시 시작해서 데이터를 꺼낸다.
  //4. sql문장을 실행한다.
 
  sql = "select * from board";
  rs = stmt.executeQuery(sql);


  // 데이타베이스에서 값을 꺼낸다.
  // 레코드가 여러줄 있을 수 있으므로 반복문을 사용한다.
 
  //5. 데이타베이스에 값이 있는지 확인한다.
  while (rs.next()) {
 
   //******주의****** 
   BoardBean boardBeanTemp = new BoardBean();
   // 템프 자바빈을 while문 안쪽에서 생성해야 데이타베이스에 있는 값을 순서대로 모두 가져 나온다.
   // 그렇지 않으면 마지막 레코드만 가져 나오게 된다.
   
/*
   //6. 값을 꺼낸다.
   int num = rs.getInt("num");
   String writer = rs.getString("writer");
   String email = rs.getString("email");
   String subject = rs.getString("subject");
   String passwd = rs.getString("passwd");
   Timestamp regDate = rs.getTimestamp("reg_date");
   int readCount = rs.getInt("read_count");
   int depth = rs.getInt("depth");
   int pos = rs.getInt("pos");
   String content = rs.getString("content");
   String ip = rs.getString("ip");

   //7. 데이타데이스에서 가져온 값은 자바빈에 담는다.
   
   boardBeanTemp.setNum(num);
   boardBeanTemp.setWriter(writer);
   boardBeanTemp.setEmail(email);
   boardBeanTemp.setSubject(subject);
   boardBeanTemp.setPasswd(passwd);
   boardBeanTemp.setRegDate(regDate);
   boardBeanTemp.setReadCount(readCount);
   boardBeanTemp.setDepth(depth);
   boardBeanTemp.setPos(pos);
   boardBeanTemp.setContent(content);
   boardBeanTemp.setIp(ip);
*/  
   //6번과 7번 함께 사용하는 방법이 일반적이다.
   boardBeanTemp.setNum(rs.getInt("num"));
   boardBeanTemp.setWriter(rs.getString("writer"));
   boardBeanTemp.setEmail(rs.getString("email"));
   boardBeanTemp.setSubject(rs.getString("subject"));
   boardBeanTemp.setPasswd(rs.getString("passwd"));
   boardBeanTemp.setRegDate(rs.getTimestamp("reg_date"));
   boardBeanTemp.setReadCount(rs.getInt("read_count"));
   boardBeanTemp.setDepth(rs.getInt("depth"));
   boardBeanTemp.setPos(rs.getInt("pos"));
   boardBeanTemp.setContent(rs.getString("content"));
   boardBeanTemp.setIp(rs.getString("ip"));
   
   //8. 자반 객체를 배열 객체 Vector 담는다.
   list.add(boardBeanTemp);
  }
 
 } catch (Exception e) {
  e.getStackTrace();
 } finally {
  //9. ResultSet 객체를 반납한다.
  if (rs != null) {
   try {
    rs.close();
   } catch (Exception e) {
   }
  }

  //10. Statement 객체를 반납한다.
  if (stmt != null) {
   try {
    stmt.close();
   } catch (Exception e) {
   }
  }

  //11. Connection 객체를 반납한다.
  if (con != null) {
   try {
    con.close();
   } catch (Exception e) {
   }
  }

 }

//화면에 출력하는 방법 4가지

 //=> 1. 기본for, 2. Enumeration while,  3. Iterator while  4. 향상된for  

//첫번째 방법 기본 for
 //12. 최대값을 찾는다.

  for (int i=0; i<list.size(); i++ ){
  
 //13. 배열에서 자바빈을 꺼낸다.
   BoardBean boardBeanTemp = list.get(i);
 
 //14. 자바빈에서 프로퍼티를 꺼낸다.

  int num = boardBeanTemp.getNum();
  String writer = boardBeanTemp.getWriter();
  String email = boardBeanTemp.getEmail();
  String subject = boardBeanTemp.getSubject();
  String passwd = boardBeanTemp.getPasswd();
  Timestamp regDate = boardBeanTemp.getRegDate();
  int readCount = boardBeanTemp.getReadCount();
  int depth = boardBeanTemp.getDepth();
  int pos = boardBeanTemp.getPos();
  String content = boardBeanTemp.getContent();
  String ip = boardBeanTemp.getIp();

 //15. 화면에 출력한다.
  out.println(num +"&nbsp;&nbsp;&nbsp;");
  out.println(writer +"&nbsp;&nbsp;&nbsp;");
  out.println(email +"&nbsp;&nbsp;&nbsp;");
  out.println(subject +"&nbsp;&nbsp;&nbsp;");
  out.println(passwd +"&nbsp;&nbsp;&nbsp;");
  out.println(regDate +"&nbsp;&nbsp;&nbsp;");
  out.println(readCount +"&nbsp;&nbsp;&nbsp;");
  out.println(depth +"&nbsp;&nbsp;&nbsp;");
  out.println(pos +"&nbsp;&nbsp;&nbsp;");
  out.println(content +"&nbsp;&nbsp;&nbsp;");
  out.println(ip +"&nbsp;&nbsp;&nbsp;");
  out.println("<br>");
   
  }
//두번째 방법  Enumeration while
  //12. 열거형 배열클래스를 생성한다.
  Enumeration<BoardBean> enu = (Enumeration<BoardBean>)list.elements();

  //13. 배열객체에 자바빈이 있는지 확인한다.
  while (enu.hasMoreElements()){
  
 //14. 배열에서 자바빈을 꺼낸다.
   BoardBean boardBeanTemp = (BoardBean)enu.nextElement();
 
 //15. 자바빈에서 프로퍼티를 꺼낸다.

  int num = boardBeanTemp.getNum();
  String writer = boardBeanTemp.getWriter();
  String email = boardBeanTemp.getEmail();
  String subject = boardBeanTemp.getSubject();
  String passwd = boardBeanTemp.getPasswd();
  Timestamp regDate = boardBeanTemp.getRegDate();
  int readCount = boardBeanTemp.getReadCount();
  int depth = boardBeanTemp.getDepth();
  int pos = boardBeanTemp.getPos();
  String content = boardBeanTemp.getContent();
  String ip = boardBeanTemp.getIp();

 //16. 화면에 출력한다.
  out.println(num +"&nbsp;&nbsp;&nbsp;");
  out.println(writer +"&nbsp;&nbsp;&nbsp;");
  out.println(email +"&nbsp;&nbsp;&nbsp;");
  out.println(subject +"&nbsp;&nbsp;&nbsp;");
  out.println(passwd +"&nbsp;&nbsp;&nbsp;");
  out.println(regDate +"&nbsp;&nbsp;&nbsp;");
  out.println(readCount +"&nbsp;&nbsp;&nbsp;");
  out.println(depth +"&nbsp;&nbsp;&nbsp;");
  out.println(pos +"&nbsp;&nbsp;&nbsp;");
  out.println(content +"&nbsp;&nbsp;&nbsp;");
  out.println(ip +"&nbsp;&nbsp;&nbsp;");
  out.println("<br>");
   
  }

  //세번째 방법  Iterator while
  //12. 열거형 배열클래스를 생성한다.
  Iterator<BoardBean> itr = list.iterator();

  //13. 배열객체에 자바빈이 있는지 확인한다.
  while (itr.hasNext()){
  
 //14. 배열에서 자바빈을 꺼낸다.
   BoardBean boardBeanTemp = (BoardBean)itr.next();
 
 //15. 자바빈에서 프로퍼티를 꺼낸다.

  int num = boardBeanTemp.getNum();
  String writer = boardBeanTemp.getWriter();
  String email = boardBeanTemp.getEmail();
  String subject = boardBeanTemp.getSubject();
  String passwd = boardBeanTemp.getPasswd();
  Timestamp regDate = boardBeanTemp.getRegDate();
  int readCount = boardBeanTemp.getReadCount();
  int depth = boardBeanTemp.getDepth();
  int pos = boardBeanTemp.getPos();
  String content = boardBeanTemp.getContent();
  String ip = boardBeanTemp.getIp();

 //16. 화면에 출력한다.
  out.println(num +"&nbsp;&nbsp;&nbsp;");
  out.println(writer +"&nbsp;&nbsp;&nbsp;");
  out.println(email +"&nbsp;&nbsp;&nbsp;");
  out.println(subject +"&nbsp;&nbsp;&nbsp;");
  out.println(passwd +"&nbsp;&nbsp;&nbsp;");
  out.println(regDate +"&nbsp;&nbsp;&nbsp;");
  out.println(readCount +"&nbsp;&nbsp;&nbsp;");
  out.println(depth +"&nbsp;&nbsp;&nbsp;");
  out.println(pos +"&nbsp;&nbsp;&nbsp;");
  out.println(content +"&nbsp;&nbsp;&nbsp;");
  out.println(ip +"&nbsp;&nbsp;&nbsp;");
  out.println("<br>");
   
  }
 
  //네번째 방법 향상된 for
  //12.자바빈을 선언한다. 그리고 타입을  자바빈을 꺼내는 배열인스턴스로 지정한다.

  for (BoardBean boardBeanTemp:list){

   //13. 자바빈에서 프로퍼티를 꺼내고 출력한다.

  out.println(boardBeanTemp.getNum() +"&nbsp;&nbsp;&nbsp;");
  out.println(boardBeanTemp.getWriter() +"&nbsp;&nbsp;&nbsp;");
  out.println(boardBeanTemp.getEmail() +"&nbsp;&nbsp;&nbsp;");
  out.println(boardBeanTemp.getSubject() +"&nbsp;&nbsp;&nbsp;");
  out.println(boardBeanTemp.getPasswd() +"&nbsp;&nbsp;&nbsp;");
  out.println(boardBeanTemp.getRegDate() +"&nbsp;&nbsp;&nbsp;");
  out.println(boardBeanTemp.getReadCount() +"&nbsp;&nbsp;&nbsp;");
  out.println(boardBeanTemp.getDepth() +"&nbsp;&nbsp;&nbsp;");
  out.println(boardBeanTemp.getPos() +"&nbsp;&nbsp;&nbsp;");
  out.println(boardBeanTemp.getContent() +"&nbsp;&nbsp;&nbsp;");
  out.println(boardBeanTemp.getIp() +"&nbsp;&nbsp;&nbsp;");
  out.println("<br>");
   
  }  
   
  session.setAttribute("list",list);  
%>
<script language="javascript"> location.href="writeResult2.jsp";</script>

======================== writeResult2.jsp =========================

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<%@ page import="java.util.Vector,testjdbc.BoardBean" %>
<!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>
<%
 
Vector<BoardBean> list = (Vector<BoardBean>)session.getAttribute("list");
for (BoardBean boardBeanTemp:list){

  //13. 자바빈에서 프로퍼티를 꺼내고 출력한다.

 out.println(boardBeanTemp.getNum() +"&nbsp;&nbsp;&nbsp;");
 out.println(boardBeanTemp.getWriter() +"&nbsp;&nbsp;&nbsp;");
 out.println(boardBeanTemp.getEmail() +"&nbsp;&nbsp;&nbsp;");
 out.println(boardBeanTemp.getSubject() +"&nbsp;&nbsp;&nbsp;");
 out.println(boardBeanTemp.getPasswd() +"&nbsp;&nbsp;&nbsp;");
 out.println(boardBeanTemp.getRegDate() +"&nbsp;&nbsp;&nbsp;");
 out.println(boardBeanTemp.getReadCount() +"&nbsp;&nbsp;&nbsp;");
 out.println(boardBeanTemp.getDepth() +"&nbsp;&nbsp;&nbsp;");
 out.println(boardBeanTemp.getPos() +"&nbsp;&nbsp;&nbsp;");
 out.println(boardBeanTemp.getContent() +"&nbsp;&nbsp;&nbsp;");
 out.println(boardBeanTemp.getIp() +"&nbsp;&nbsp;&nbsp;");
 out.println("<br>");
  
}


</body>
</html>

top

Trackback Address :: http://www.ssial.com/trackback/129 관련글 쓰기

  1. Chanel Outlet 2011/09/17 21:27 댓글주소 | 수정/삭제 | 댓글

    Time is what you make of it.

  2. Chanel Outlet 2011/09/17 21:27 댓글주소 | 수정/삭제 | 댓글

    Time is what you make of it.

  3. Burberry Bags 2011/10/13 17:03 댓글주소 | 수정/삭제 | 댓글

    I'm happy I found this blog! From time to time students want to cognitive the keys of productive literary essays composing. Your first-class knowledge about this good post can become a proper basis for such people. Thanks.

  4. Coach Outlet Online 2011/11/15 12:44 댓글주소 | 수정/삭제 | 댓글

    I'm happy I found this blog ! It's very good and thank you for sharing it !

Write a comment


JSP roof test

JSP/Basic 2008/10/15 14:38
==================  testForm.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>
숫자를 입력하세요! <br>력한 숫자가 10보다 작거나 큰가요? 전송 받는 페이지에서 알 수 있습니다..
<form method="post" action="testProc.jsp" name="insertForm"><input name="num" type="text"><input type="submit" name="submit" value="전송"></form>
</body>
</html>


==================  testProc.jsp (1)  ============================

<%@ 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 number = "0123456789";
boolean check = true;
if (request.getParameter("num")!=""){
 String tmpNum = request.getParameter("num");
 for (int i = 0; i < tmpNum.length(); i++){
  // tmpNum.charAt(i)
  if(tmpNum.charAt(i)<48 || tmpNum.charAt(i)>58){
   check = false;
   break;
  }
 }
 if (check){
  int num = Integer.parseInt(tmpNum);
  if (num<=10){
   out.println("입력한 숫자 " +num+ "은(는) 10보다 작거나 같습니다.");
  }else{
   out.println("입력한 숫자 " +num+ "은(는) 10보다 큽니다.");
  }
 }else{
  out.println(" 숫자를 입력하지 않았습니다." + tmpNum + "숫자가 아닙니다.");
 }
}else{
%>
 <%="숫자를 입력해 주세요!" %>
<%
}
%>
<br>
<br>
<a href="testForm.jsp">처음으로 돌아가기</a>
</body>
</html>

==================  testProc.jsp (2)   ============================

<%@ 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 number = "0123456789";
boolean check = true;
if (request.getParameter("num")!=""){
 String tmpNum = request.getParameter("num");
 next:{
  for (int i = 0; i < tmpNum.length(); i++){
   for (int j = 0; j<number.length(); j++){
   // tmpNum.charAt(i)
    if(tmpNum.charAt(i)!= number.charAt(i)){
     check = false;
     break next;
    }
   }
  }
 }
 if (check){
  int num = Integer.parseInt(tmpNum);
  if (num<=10){
   out.println("입력한 숫자 " +num+ "은(는) 10보다 작거나 같습니다.");
  }else{
   out.println("입력한 숫자 " +num+ "은(는) 10보다 큽니다.");
  }
 }else{
  out.println(" 숫자를 입력하지 않았습니다." + tmpNum + "숫자가 아닙니다.");
 }
}else{
%>
 <%="숫자를 입력해 주세요!" %>
<%
}
%>
<br><br>
<a href="testForm.jsp">처음으로 돌아가기</a>
</body>
</html>
top

Trackback Address :: http://www.ssial.com/trackback/116 관련글 쓰기

  1. Burberry Bags 2011/10/13 16:53 댓글주소 | 수정/삭제 | 댓글

    I'm happy I found this blog! From time to time students want to cognitive the keys of productive literary essays composing. Your first-class knowledge about this good post can become a proper basis for such people. Thanks.

  2. Coach Outlet Online 2011/11/15 12:40 댓글주소 | 수정/삭제 | 댓글

    It's very good!Thank you for sharing it!I like buying handbags of the internet website:http://www.mycoachoutletstoreonline.com

Write a comment