달력

42024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

요즘 종종 이러하신분들 계시죠?

   


   

별거 아니다.

그냥 이렇게만 하면된다.

   

내컴퓨터->구성->폴더 및 검색 옵션->보기

   

      

   

   

   

   

   

   

   

   

'IT > 기타' 카테고리의 다른 글

mRemote 원격 데스크탑에서 파일복사  (0) 2010.06.07
Posted by 만들고보자
|

1.WEB-INF/lib 에 위치할 jar파일

Struts2관련

commons-fileupload.jar

commons-io.jar

freemarker.jar

ognl.jar

struts2-core.jar

xwork.jar

Spring관련

Struts2-spring-plugin.jar

Spring.jar

ibatis 및 DBCP, log4j, JSTL 기타등등

commons-dbcp.jar

commons-logging.jar

commons-pool.jar

ibatis.jar

log4j.jar

jstl.jar

standard.jar

sqljdbc.jar

commons-collection.jar

commons-lang.jar

   

   

2.web.xml

스트러츠2 관련

<filter>

<filter-name>struts2</filter-name>

<filter-class>

org.apache.struts2.dispatcher.FilterDispatcher

</filter-class>

</filter>

   

<filter-mapping>

<filter-name>struts2</filter-name>

<url-pattern>/*</url-pattern>

</filter-mapping>

   

스프링 관련

<!--컨텍스트 로더 리스너에서 읽는 applicationContext 설정 파일 위치 지정-->

<context-param>

<param-name>contextConfigLocation</param-name>

<param-value>

/WEB-INF/applicationContext*.xml

</param-value>

</context-param>

<!--컨텍스트 로더 리스너 지정-->

<listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

</listener>

   

   

3.applicationContext.xml

   

dtd 선언

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:aop="http:/www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"

xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.0.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-2.0.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">

   

jdbc.property 파일 로딩(DB 접속 관련 정보)

<bean id="propertyConfigurer"

class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

<property name="locations">

<list>

<value>WEB-INF/config/jdbc.properties</value>

</list>

</property>

<property name="fileEncoding">

<value>UTF-8</value>

</property>

</bean>

   

<!--apache의 DBCP Connection Pool 사용-->

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"

destroy-method="close">

<property name="driverClassName" value="${jdbc.driverClassName}"/>

<property name="url" value="${jdbc.url}"/>

<property name="username" value="${jdbc.username}"/>

<property name="password" value="${jdbc.password}"/>

</bean>

<!--iBATIS SQLMaps의 설정 SqlMap setup for iBATIS Database Layer -->

<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">

<property name="configLocation">

<value>WEB-INF/config/sqlmapConfig.xml</value>

</property>

<property name="dataSource" ref="dataSource"/>

</bean>

   

   

<!--Transaction manager for iBATIS Daos

DB연결에 관련된 설정을 DataSource 형태로 지정을 했기 때문에 Transaction 관리를 Spring의 DataSourceTransactionManager가 담당하도록 지정한다.-->

<bean id="txManager"

class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

<property name="dataSource">

<ref local="dataSource"/>

</property>

</bean>

<!-- Enable @Transactional support

Business Logic 클래스(여기서는 *ServiceImpl 클래스)에 어노테이션으로 한줄로 해결 할수 있다는데 확실히 아직 모르겠음. 그외 방법으로 Spring의 AOP, Advice를 이용 -->

<tx:annotation-driven transaction-manager="txManager"/>

   

   

4.sqlmapConfig.xml

<!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"

"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">

<!--

elecment XML 파일을 이용하여 build되는 다양한 옵션과 SQL Map Client instance를

최적화 하기 위한 설정들 이다.

setting element 와 모든 attributes는 모두 선택옵션이다.

-->

<sqlMapConfig>

<settings cacheModelsEnabled="true" classInfoCacheEnabled="true"

errorTracingEnabled="true" enhancementEnabled="true"

lazyLoadingEnabled="true" maxRequests="512"

maxSessions="128" maxTransactions="32"

useStatementNamespaces="true" />

<!- 해당 SQL문서 위치-à

<sqlMap resource="com/rainmac/dao/ibatis/board-dao.xml"/>

<sqlMap resource="com/rainmac/dao/ibatis/user-dao.xml"/>

<sqlMap resource="com/rainmac/dao/ibatis/attachFile-dao.xml"/>

   

</sqlMapConfig>

   

   

5.struts.xml

<struts>

<constant name="struts.objectFactory" value="spring" />

<package name="default" extends="struts-default" >

<action name="main" method="main" class="mainAction">

<result>/main.jsp</result>

<result name="input">/main.jsp</result>

</action>

</package>

   

<include file="/com/rainmac/action/user.xml" />

<include file="/com/rainmac/action/board.xml"/>

<include file="/com/rainmac/action/attachFile.xml"/>

</struts>

   

   

6.board.xml

   

<package name="board" namespace="/board" extends="struts-default">

<!-- Board -->

<action name="boardList" method="boardList" class="boardAction" >

<result name="success">/view/board/boardList.jsp</result>

<result name="input">/view/board/boardList.jsp</result>

</action>

<action name="boardUpdate" method="boardUpdate" class="boardAction">

<result type="chain" name="success">boardList</result>

</action>

</package>

   

   

7. applicationContext.xml

   

<bean id="boardService" class="com.rainmac.serviceImpl.BoardServiceImpl">

<property name="boardDao" ref="boardDao"/>

<property name="articleDao" ref="articleDao"/>

<property name="attachFileService" ref="attachFileService"/>

</bean>

<bean id="boardDao" class="com.rainmac.dao.ibatis.BoardDaoiBatis">

<property name="sqlMapClient" ref="sqlMapClient"/>

</bean>

<bean id="boardAction" class="com.rainmac.action.BoardAction" scope="prototype">

<property name="boardService" ref="boardService"/>

<property name="articleService" ref="articleService"/>

<property name="userService" ref="userService"/>

</bean>

   

   

8.BoardServiceImpl.java

public class BoardServiceImpl implements BoardService{

private BoardDao boardDao;

private AttachFileService attachFileService;

private ArticleDao articleDao;

public void setArticleDao(ArticleDao articleDao) {

this.articleDao = articleDao;

}

public void setAttachFileService(AttachFileService attachFileService) {

this.attachFileService = attachFileService;

}

   

public void setBoardDao(BoardDao boardDao) {

this.boardDao = boardDao;

}

public List getBoards() {

return boardDao.getBoards();

}

public Object getBoardInfo(HashMap<String, Object> map){

return boardDao.getBoardInfo(map);

}

}

   

   

9.흐름

*Action >> *Service(Interface) >> *ServiceImpl >> *DAO(Interface) >> *DaoiBatis

   

   

Posted by 만들고보자
|

iBatis 트랜잭션

IT/DataBase 2010. 6. 7. 14:56

SqlMapClient sqlMap = getSqlMapClient();

   

try{

sqlMap.startTransaction();

sqlMap.startBatch();

   

//여기에 쿼리호출

sqlMap.executeBatch();

sqlMap.commitTransaction();

   

}catch (Exception e) {

// TODO: handle exception

}finally{

sqlMap.endTransaction();

}

Posted by 만들고보자
|

// 자바 스크립트 부분

   

function SetNum(obj){

 val=obj.value;

 re=/[^0-9]/gi;

 obj.value=val.replace(re,"");

}

   

   

//호출할 부분

<input type=text name=test onkeypress='SetNum(this)' onblur='SetNum(this)'>

   

   

//소스 설명

작업을 하다보면 숫자만 입력을 받아야 하는 경우 사용자가 숫자아닌 다른 것들을 입력하면 입력이 되지 않도록 한다.

   

'IT > JavaScript' 카테고리의 다른 글

jQuery 기반 쓸만한 Library들  (0) 2009.12.28
Posted by 만들고보자
|

Tomcat 6.0 사이트 여러개 운영

TOMCAT/사이트 여러개 운영 2010/04/05 13:30

잘되어 있는 사이트를 포스팅 해왔다.

   

Tomcat Web application 만들기 

먼저, 웹 루트를 어디로 정할 것인가?

(아파치나 톰캣 자체가 static html을 바라보는 웹 웹루트)

   

톰켓이 기본적으로 보고 있는 루트 컨텍스트는 webapps/ROOT 이다.

server.xml 내용을 보면

  1. 96:  <Host name="localhost"  appBase="webapps"
                unpackWARs="true" autoDeploy="true"
                xmlValidation="false" xmlNamespaceAware="false">

와 같이 appBase는 ${catalina-home} 밑의 상대경로를 인자로 받으며,기본적으로 보안과 context의 통일적인 적용을 이유로 컨텍스트의 루트는 ROOT 디렉토리 밑이 됩니다.

따라서, 톰켓이 설치가 되면 웹루트는 ${catalina-home}/webapps/ROOT 가 된다.

(위의 과정대로 설치했다면 우리 시스템에서는 /usr/local/tomcat/webapps/ROOT 가 된다)

 이를 3가지 형태로 변경해 사용할 수 있다.

1. webapp 자체를 웹루트 디렉토리로 만들고 싶을 때,

단지, <Host> 태그 내에 아래와 같은 컨텍스트를 추가하면 됩니다.

    <Context path="" docBase="." reloadable="true"/>

   사실 컨텍스트는 더 많은 옵션이 있으나 여기는 최소한의 사항만 적었습니다. 실서버에 적용할 때는 log 부분도 신경을 써주셔야 합니다. 더 자세한 사항은 웹을 검색해 보시기 바랍니다.

2. webapp/test/ROOT를 웹루트 디렉토리로 만들고 싶을 때,

  1. 96:  <Host name="localhost"  appBase="webapps/test"
                unpackWARs="true" autoDeploy="true"
                xmlValidation="false" xmlNamespaceAware="false">

3. /home/dev/appName 을 웹루트 디렉토리로 만들고 싶을 때

  1. 96:  <Host name="localhost"  appBase="/home/dev/appName" unpackWARs="true" autoDeploy="true"
                xmlValidation="false" xmlNamespaceAware="false">
  2.     <Context path="" docBase="." reloadable="true"/>
        </Host>

     또는,

  1. 96:  <Host name="localhost"  appBase="/home/dev"
                unpackWARs="true" autoDeploy="true"
                xmlValidation="false" xmlNamespaceAware="false">

        <Context path="" docBase="mywebappdir" reloadable="true"/>
        </Host>

   Context 를 빼먹으면 ROOT를 자동으로 웹루트로 쓴다.

3번의 설명은 Host의  appBase 경로를 다른 곳으로 돌린 경우에 해당한다.

이러한 경우 다음 항목인 " 별도의 디렉토리를 appBase로 잡을 경우 설정" 내용을 참고하여 진행해야 한다.

우리 시스템(2008년8월 개발서버)은 3번과 같이 별도의 경로를 web, app Base디렉토리로 잡고 진행한다.

   

   

p.s.> 톰켓 5.0부터 추가적인 context는 server.xml에 추가하지 않고,

각 웹어플리케이션 디렉토리 별로 META-INF 밑에 context.xml을 추가하게 됩니다.

웹루트를 appBase와 같이 하려면 이의 설정을 server.xml에서 설정해도 무방한 것 같습니다만,

webapps를 루트로 쓰는 것은 특별한 경우가 아니면 지양하는 게 좋으며,

꼭 필요하다면 apache의 redirect를 쓰는 방법 등으로 해결할 수도 있습니다.

   

별도의 디렉토리를 웹 컨텍스트 루트로 잡을 경우 설정과정

  • 우리 시스템은 다른 하드디스크에 별도로 디렉토리를 생성하였다.
    이는 /media/disk 로 마운트되어 있다.
  • /media/disk/webapps 디렉토리를 생성해 권한을 사용가능한 일반유저 권한으로 설정한다(mkdir, chown 등 사용)
  • 위 디렉토리에 컨텍스트가 될 "test" 디렉토리를 만들고 시험적으로 되는지 확인해 볼 만한 index.jsp 파일 하나를 아래와 같이 대충 만들어 넣는다.
  1. <html>
    <head><title>TEST-INDEX</title>
    <body>
    <h1>INDEX</h1>
    </body>
    </html>

   

톰캣 관리자 화면에서 새로운 어플리케이션이 보여지게 하려면  TOMCAT_HOME /work/Catalina/호스트명(localhost)/{컨텍스트명}test.xml 파일을 아래와 같이 만들어 넣으면

  1. <?xml version='1.0' encoding='utf-8'?>
    <Context path="/test"
             docBase="/media/disk/webapps/test"
             debug="0"
             reloadable="true"
             crossContext="true"
    />

톰캣 관리자 화면에서 확인이 될 수 있다.

즉, 호스트 밑에 컨텍스트명과 동일한 컨텍스트 xml 파일을 넣으면 된다는 것이지만, 런타임에만 적용되므로 환경설정에 완전히 적용하기 위해선 컨텍스트 설정에 관한 자세한 설정은 Tomcat 6 컨텍스트 설정방법 을 참고한다.

TOMCAT_HOME : 톰캣 설치 디렉터리

   

1. 도메인으로 분류하는 방법

   

TOMCAT_HOME\conf\server.xml 을 열면 기본적으로 하나의 Service 엘리먼트가 있고

그 하위에 Engine 엘리먼트가, 또 그 하위에 아래와 같은 하나의 Host 엘리먼트가 있다.

   

      <Host name="localhost"  appBase="webapps"

            unpackWARs="true" autoDeploy="true"

            xmlValidation="false" xmlNamespaceAware="false">

      </Host>

   

아래와 같이 추가하려는 도메인으로 Host 엘리먼트를 하나 더 추가한다.

   

      <Host name="localhost"  appBase="webapps"

            unpackWARs="true" autoDeploy="true"

            xmlValidation="false" xmlNamespaceAware="false">

      </Host>

      <Host name="test.sisinfo.comappBase="/media/disk/webapps/test"

            unpackWARs="true" autoDeploy="true"

            xmlValidation="false" xmlNamespaceAware="false">

      </Host>

   

appBase는 이 컨텍스트의 물리적 영역이 되겠다.

물론 실제의 물리적인 디렉터리도 아래와 같이 필요하다.

   

/media/disk/webapps/test/ROOT

/media/disk/webapps/test/ROOT/WEB-INF

   

WEB-INF의 web.xml등은 TOMCAT_HOME/webapps/ROOT/WEB-INF에서 복사한다.

   

/media/disk/webapps/test/ROOT 디렉터리는 이 컨텍스트의 루트 디렉터리로 작동한다.

   

여기서 test.sisinfo.com은 추가하려는 도메인이 되겠으며,

실제로 도메인을 보유하지 않고 개발 PC에서 작업하는 경우,

C:\Windows\system32\drivers\etc\hosts 파일을 열고

마지막 줄에 다음을 추가한다.

   

192.168.10.105      test.sisinfo.com

   

이제 웹브라우저를 열고 [test.sisinfo.com:포트번호]에 접속하면 된다.

   

만일 /media/disk/webapps/test/ROOT 가 아닌 /media/disk/webapps/test 를 룰트 디렉터리로 사용하고자 하는 경우에는

server.xml을 다음과 같이 작성한다.

      <Hostname="localhost"  appBase="webapps"

            unpackWARs="true" autoDeploy="true"

            xmlValidation="false" xmlNamespaceAware="false">

      </Host>

      <Host name="test.sisinfo.com"  appBase="/media/disk/webapps/test"

            unpackWARs="true" autoDeploy="true"

            xmlValidation="false" xmlNamespaceAware="false">

    <context path="" docBase="/media/disk/webapps/test"></context>

      </Host>

   

2. 포트 번호로 분류하는 방법

   

톰캣에서도 MS의 IIS와 같이 포트 번호에 따라 호스팅하는 것이 가능하다.

TOMCAT_HOME\conf\server.xml 을 열고 아래와 같이 Service 엘리먼트를 추가한다.

   

  <Service name="testdomain">

    <Connector port="8090" protocol="HTTP/1.1"

               connectionTimeout="20000"

               redirectPort="8443" />

    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

    <Engine name="testdomain" defaultHost="localhost">

      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"

             resourceName="UserDatabase"/>

      <Host name="localhost"  appBase="C:\testdomain"

            unpackWARs="true" autoDeploy="true"

            xmlValidation="false" xmlNamespaceAware="false">

            <context path="" docBase="C:\testdomain"></context>

      </Host>

    </Engine>

  </Service>

   

Service 엘리먼트의 name 속성은 추가하려는 컨텍스트의 이름이 되겠다.

첫 Connector 엘리먼트의 port 속성은 사용하려는 포트 번호를 넣으면 된다.

Host 엘리먼트와 context 엘리먼트, appBase에 대한 물리적 경로 생성은 1항의 설명과 같다.

   

이제 웹브라우저를 열고 [localhost:포트번호]에 접속하면 된다.

   

   

   

   

   

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

   

아파치와 연동없이 톰캣만으로도 하나의 IP로 다수의 웹사이트를 운영하는 것이 가능하다.

(아파치와 톰캣을 연동하는 방법에 대해서는 차후에 자세히 올리도록 하겠다)

   

특히 개발자의 경우 여러개의 프로젝트를 개발하거나 테스트하고자 할 때 웹사이트를 여러개 운영해야한다. 다수의 웹 사이트를 세팅하는 방법은 크게 2가지가 있다.

가상호스트를 이용하는 방법은 도메인을 이용하여 실제로 서비스를 운영하는 경우가 아니면 개발자에겐 별 의미가 없다. 여기서는 두번째 방법인 IP 어드레스의 포트를 이용하는 방법에 대해서 설명하겠다. (바로가기 : 톰캣에서 가상 호스트를 이용하는 방법)

우선 설치 환경은 다음과 같다.

  • O/S : Windows XP (난 아직 리눅스를 잘 모른다. 비슷하겠지만 테스트해보지 않았다)
  • Tomcat 6.0 (정확히는 6.0.10) : 다운로드

설명의 편의를 위해 톰캣의 설치 디렉토리는 'TOMCAT_HOME' 으로 표기할 것이다. 참고로 내 경우는 C:\Server\Tomcat6.0 이다.

   

설정하는 방법은 간단하다. /TOMCAT_HOME/conf/에 있는 server.xml 파일만 수정하면 끝이다. server.xml의 쓸데없는 주석부분을 다 없애고 핵심부분만 남겨놓으면 아래와 같다.

   

<Service name="Catalina">

  <Connector port="8080" protocol="HTTP/1.1"

   maxThreads="150" connectionTimeout="20000"

   redirectPort="8443" />

  <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

  <Engine name="Catalina" defaultHost="localhost">

   <Realm className="org.apache.catalina.realm.UserDatabaseRealm"

    resourceName="UserDatabase"/>

   <Host name="localhost"  appBase="webapps"

    unpackWARs="true" autoDeploy="true"

    xmlValidation="false" xmlNamespaceAware="false">

   </Host>

  </Engine>

 </Service>

   

   

우선 빨간색으로 표시한 부분만 이해하고 넘어가도 상관없다.

Connector port="8080"은 HTTP로 넘어오는 포트를 지정하는 것이다. 톰캣의 기본 포트가 8080인 이유가 여기에 있다. 따라서 8080 대신 기본 80포트를 사용하고 싶다면? 바로 이 부분을 port="80"으로 바꾸어주면 된다.

   

다음, Host 지시어의 appBase="webapps" 는 웹어플리케이션(웹사이트)의 위치를 나타낸다. appBase="./webapps"와 같은 의미다. 실제 위치는 TOMCAT_HOME/webapps이다. 물론 "d:/weapps/myweb1" 과 같이 절대경로로 지정하는 것도 가능하다.

   

그럼 웹사이트를 하다 더 추가하고 싶다면? 위의 <Service>...</Service>를 하나 더 만들어 버리면 된다. 위의 코드를 복사한 다음 server.xml 에 추가한다. 그리고 빨간색으로 표시한 부분만 수정하자.

   

<Service name="Catalina2">

  <Connector port="9090" protocol="HTTP/1.1"

     maxThreads="150" connectionTimeout="20000"

     redirectPort="8443" />

  <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

   

  <Engine name="Catalina" defaultHost="localhost">

   <Realm className="org.apache.catalina.realm.UserDatabaseRealm"

     resourceName="UserDatabase"/>

   

   <Host name="localhost"  appBase="d:/webapps/myweb2"

    unpackWARs="true" autoDeploy="true"

    xmlValidation="false" xmlNamespaceAware="false">

   </Host>

  </Engine>

 </Service>

   

다른 웹어플리케이션을 돌리기 위해 서비스를 하나 더 추가한 것이다.

port="9090" 은 새로 추가하고 싶은 포트이다.

appBase="d:/webapps/myweb2"는 9090 포트에서 돌아갈 웹사이트 위치이다.

   

이제 server.xml 설정은 끝난 것이다.

마지막으로 웹사이트의 ROOT 디렉토리를 지정해주자. 아래의 폴더를 생성한다.

   

d:/webapps/myweb2/ROOT/   (

d:/webapps/myweb2/ROOT/WEB-INF/

(WEB-INF 폴더를 만들고 web.xml 파일을 추가한다. 그냥 /TOMCAT_HOME/webapps/ROOT/WEB-INF/에 있는 web.xml 을 복사하면 된다.

   

무지 간단하다. 하지만 난 이 간단한 것을 위해서 하루종일 삽질해야만 했다. 검색해 보아도 문서는 많은데 실제 도움이 될만한 것이 별로 없었다.

   

테스트하기 위해 ROOT/index.html 또는 index.jsp를 만든다.

이제 톰캣을 재시작하고 웹브라우저로 접속해 보자.

http://localhost:8080

http://localhost:9090

   

   

   

   

   

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

   

톰캣에서 하나의 IP로 여러개의 웹사이트를 운영하는 방법은 2가지가 있다.

여기서는 가상 호스트를 이용하여 톰캣에서 여러개의 웹사이트를 운영하는 방법에 대해서 설명하고자 한다.

설치 환경은 다음과 같다.

  • O/S : Windows XP (Windows Server 동일)
  • Tomcat 6.0.10

설명의 편의를 위해 톰캣의 설치 디렉토리는 'TOMCAT_HOME' 으로 표기할 것이다. 참고로 내 경우는 C:\Server\Tomcat6.0 이다.

설정하는 방법은 /TOMCAT_HOME/conf/에 있는 server.xml 파일만 수정하면 된다. server.xml의 쓸데없는 주석부분을 다 없애고 관련 부분만 남겨놓으면 아래와 같다.   

<Service name="Catalina">

      <Connector port="8080" protocol="HTTP/1.1"

       maxThreads="150" connectionTimeout="20000"

       redirectPort="8443" />

      <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

      <Engine name="Catalina" defaultHost="localhost">

       <Realm className="org.apache.catalina.realm.UserDatabaseRealm"

        resourceName="UserDatabase"/>

       <Host name="localhost"  appBase="webapps"

        unpackWARs="true" autoDeploy="true"

        xmlValidation="false" xmlNamespaceAware="false">

       </Host>

      </Engine>

     </Service>

위의 내용에서 핵심 부분은 <Host></Host> 영역이다.

1. 우선 <Connector port="8080" protocol="HTTP/1.1" 부분의 port를 80으로 수정한다.

  도메인명이 기본으로 80포트를 사용하기 때문이다.

   

2. <Host>... </Host> 에 해당하는 부분을 복사하여 2개를 만든다. 그리고 이렇게 수정하자.

        

<Host name="www.myweb1.com"  appBase="d:/webapps/myweb1"

        unpackWARs="true" autoDeploy="true"

        xmlValidation="false" xmlNamespaceAware="false">

       </Host>

       <Host name="www.myweb2.com"  appBase="d:/webapps/myweb2"

        unpackWARs="true" autoDeploy="true"

        xmlValidation="false" xmlNamespaceAware="false">

       </Host>

  appBase="webapps" 는 톰캣의 기본 웹루트인 TOMCAT_HOME/webapps 디렉토리를 가르킨다. 웹사이트를 원하는 디렉토리에 두고 싶다면 d:/webapps/myweb1 처럼 자기가 지정하고 싶은 곳으로 수정하면 된다.

   

3. 마지막으로 웹사이트들의 ROOT 디렉토리를 지정해주자. 아래의 폴더를 생성한다.

d:/webapps/myweb1/ROOT/

d:/webapps/myweb1/ROOT/WEB-INF/

d:/webapps/myweb2/ROOT/

d:/webapps/myweb2/ROOT/WEB-INF/

그리고 WEB-INF 폴더 밑에 각각 web.xml 파일을 추가한다. 그냥 /TOMCAT_HOME/webapps/ROOT/WEB-INF/에 있는 web.xml 을 복사하면 된다.

4. 테스트하기 위해 ROOT/index.html 또는 index.jsp를 만든다.

이제 톰캣을 재시작하고 웹브라우저로 접속해 보자.

http://www.myweb1.com

http://www.myweb2.com

정말 간단하지 않은가?

[출처] 톰캣 6 웹사이트 여러개 운영 - virtual host, ip port, (service, engine, host context)|작성자 제리텍

   

   

원본 위치 <http://shonm.tistory.com/220?srchid=BR1http%3A%2F%2Fshonm.tistory.com%2F220>

   

'IT > WAS' 카테고리의 다른 글

Tomcat 포트 설정  (0) 2010.06.07
Posted by 만들고보자
|

'IT > 기타' 카테고리의 다른 글

레이블이 없다구 생쑈할때.  (0) 2010.06.07
Posted by 만들고보자
|

Tomcat 포트 설정

IT/WAS 2010. 6. 7. 14:47

   

TomcatHOME/conf/server.xml 에서 Connector 요소의 port 속성을 바꾸면 된다.

바꾸고 톰켓 재시작 하면 적용 완료.

'IT > WAS' 카테고리의 다른 글

Tomcat 설정(server.xml(context))  (0) 2010.06.07
Posted by 만들고보자
|

흑흑… 개삽질의 연속이었다.. 영우와 내가 미친듯이 검색한 결과.. 운좋게 jcifs 라이브러리가 내눈앞에 나타났다… 오오 신과같은 존재아.. 백번 말해봤자 소용없다 일단 소스코드 고고~

   

import java.util.Enumeration;

import java.util.Hashtable;

import jcifs.smb.SmbFile;

   

public class test5 {

public static void main(String[] args) throws Exception {

SmbFile root = new SmbFile("smb://도메인");

Hashtable printerHash = new Hashtable();

   

searchForPrinters(root, printerHash);

   

Enumeration keys = printerHash.keys();

System.out.println("Number of Printers Found: " + printerHash.size());

SmbFile file = null;

while (keys.hasMoreElements()) {

file = ((SmbFile)keys.nextElement());

System.out.println("UNC: " + file.getUncPath());

}

}

   

private static void searchForPrinters(SmbFile root, Hashtable printers) throws Exception {

SmbFile[] kids= null;

   

try {

kids = root.listFiles();

} catch (Exception e) {

}

if (kids == null)

return;

for (int i = 0; i < kids.length; i++) {

if (kids[i].getType() == SmbFile.TYPE_WORKGROUP || kids[i].getType() == SmbFile.TYPE_SERVER)

searchForPrinters(kids[i], printers);

else if (kids[i].getType() == SmbFile.TYPE_PRINTER) {

printers.put(kids[i], Boolean.TRUE);

}

}

}

   

}

   

간단한 예제 코드이다. 후.. 결국 해당 도메인에 접근해서 그 도메인에 물려있는 프린터 목록(물론 네트워크 공유되어있는 프린터다)을 가져온다.. 후후..

우리나라 사이트엔 좀처럼 사용한 사람을 보지 못해서 해외사이트 정독했다..

이러다 영어 늘겠어-_-..

   

암튼 멋진 경험이었어..-_-...

'IT > JAVA' 카테고리의 다른 글

1.WEB-INF/lib 에 위치할 jar파일  (0) 2010.06.07
스프링 정의할때 xml 스키마 모음  (0) 2009.12.28
Java Web 개발자들을 위한 학습 로드맵  (0) 2009.12.22
Java 도움되는 사이트(Site) 목록  (0) 2009.12.21
Velocity error  (0) 2009.12.17
Posted by 만들고보자
|

commonConcern2.0

   

 <beans xmlns="http://www.springframework.org/schema/beans"

 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

 xmlns:aop="http://www.springframework.org/schema/aop"

 xsi:schemaLocation="http://www.springframework.org/schema/beans  

       http://www.springframework.org/schema/beans/spring-beans-2.0.xsd

       http://www.springframework.org/schema/aop

       http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

   

commonconcern2.5

   

<beans xmlns="http://www.springframework.org/schema/beans"

 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

 xmlns:aop="http://www.springframework.org/schema/aop"

 xsi:schemaLocation="http://www.springframework.org/schema/beans  

       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

       http://www.springframework.org/schema/aop

       http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">

   

applicationcontext 2.0

   

<beans xmlns="http://www.springframework.org/schema/beans"

 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

 xsi:schemaLocation="http://www.springframework.org/schema/beans  

       http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

applicationcontext 2.5

   

<beans xmlns="http://www.springframework.org/schema/beans"

 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

 xsi:schemaLocation="http://www.springframework.org/schema/beans  

       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

dispatcher-servlet.xml 2.0

   

<beans xmlns="http://www.springframework.org/schema/beans"

 xmlns:p="http://www.springframework.org/schema/p"

 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

 xsi:schemaLocation="http://www.springframework.org/schema/beans  

       http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

dispatcher-servlet.xml 2.5

   

<beans xmlns="http://www.springframework.org/schema/beans"

 xmlns:context="http://www.springframework.org/schema/context"

 xmlns:p="http://www.springframework.org/schema/p"

 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

 xsi:schemaLocation="http://www.springframework.org/schema/beans  

       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

       http://www.springframework.org/schema/context

       http://www.springframework.org/schema/context/spring-context-2.5.xsd">

applicationContext.xml 2.0

   

<beans xmlns="http://www.springframework.org/schema/beans"

 xmlns:p="http://www.springframework.org/schema/p"

 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

 xsi:schemaLocation="http://www.springframework.org/schema/beans  

       http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

applicationContext.xml 2.5

   

<beans xmlns="http://www.springframework.org/schema/beans"

 xmlns:p="http://www.springframework.org/schema/p"

 xmlns:context="http://www.springframework.org/schema/context"

 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

 xsi:schemaLocation="http://www.springframework.org/schema/beans  

       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

       http://www.springframework.org/schema/context  

       http://www.springframework.org/schema/context/spring-context-2.5.xsd">

applicationContextAnnot.xml 2.5

   

<beans xmlns="http://www.springframework.org/schema/beans"

 xmlns:p="http://www.springframework.org/schema/p"

 xmlns:context="http://www.springframework.org/schema/context"

 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

 xsi:schemaLocation="http://www.springframework.org/schema/beans  

       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

       http://www.springframework.org/schema/context  

       http://www.springframework.org/schema/context/spring-context-2.5.xsd">

   

applicationContextScan.xml 2.5

   

<beans xmlns="http://www.springframework.org/schema/beans"

 xmlns:p="http://www.springframework.org/schema/p"

 xmlns:context="http://www.springframework.org/schema/context"

 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

 xsi:schemaLocation="http://www.springframework.org/schema/beans  

       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

       http://www.springframework.org/schema/context  

       http://www.springframework.org/schema/context/spring-context-2.5.xsd">

Posted by 만들고보자
|

금번 프로젝트에 jQuery와 이를 기반으로 한 UI Library들을 사용해서 해 보았습니다.

혹시, 비슷한  내용으로 프로젝트를 진행할  분들에게 도움이 되었으면 해서 간단하게 나마 사용한 Library에 대한 소개를 하고자 합니다.

   

사용한 Library는 다음과 같습니다.

  jQuery Core는 말 그대로 핵입니다. ^^; 다른 Library들은 다 이 걸 기반으로 작동하도록 만들어진거죠. 해당 사이트에 보시면 Reference나 Tutorial 등이 있으니 하나씩 따라해 보시면 jQuery 식의 프로그래밍에 대한 감을 잡으실 수 있을 겁니다. 이 것만 익혀서 적용하셔도 기존의 JavaScript 코드를 상당 부분 줄일 수 있습니다. jQuery의 장점이 여러가지가 있지만 제가 제일 맘에 들어하는 건 DOM 구조를 다루는데 간편한 함수를 제공하고 속도가 빠르다는 점입니다. 그냥 HTML을 문자열로 만들어서 대상 태그 아래로 넣든지 교체하든지 앞에 넣든지 뒤에 넣든지 다 할 수 있습니다.

  그리고 요즘 JavaScript Library들의 특징이 CSS 3 식의 Selector를 사용하게 하는 건데요. 이게 정말 강력합니다. 여기선 간단한 소개 내용이니 구체적인 건 설명하지 않겠습니다. 문서를 보세요. ^^

   

  jQuery UI는 jQuery 에서 공식적으로 진행하고 있는 UI  Library입니다. 현재는 기반이 되는 기능과 특수효과, 그리고, 가장 많이 사용할 것으로 여겨지는 Widget 들을 제공하고 있습니다.

그리고, 강력한 테마기능을 갖추고 있습니다. 다른 UI 플러그인 들이 이를 기반으로 작성하면 테마가 같이 적용됩니다. 테마는 이미 등록된 것을 사용할 수도 있구요. Theme Roller 에서 자신만의 테마를 정의할 수도 있는데, 기등록된 테마를 기반으로 할 수도 있습니다. 예제에 보면 동적으로 테마를 바꾸는 기능이 있는데요, Cookie 에 선택한 값을 저장하도록 되어 있어서 개인마다 취향대로 테마를 선택할 수도 있습니다.

  이 Library가 기대가 많이 됩니다. Wiki 쪽에 보면 여러 Widget들이 개발중인 걸 보실 수 있습니다.

   

  jQuery Grid는 말 그대로 Grid 기능입니다. 이번에 사용해 본 결과 상당히 만족스럽네요. Grid가 가져야할 기본 기능 외에도 Tree Grid 기능도 있고, Subgrid 기능도 갖추고 있습니다. Tree Grid 는 한 칼럼만 사용하면 그냥 간단한 Tree 처럼 사용할 수도 있습니다. 아쉬운 건 한국형 표에서 많이 나오는 다중 칼럼이 안 된다는 거요. ^^; 이건 그냥 출력용으로 HTML로 구현하면 될 듯.

  이 Grid는 여기서 소개하기에는 너무 많은 기능을 자랑합니다. Grid 자체에서 새 항목을 등록하거나 수정하는 기능을 칼럼에 대한 설정만으로도 가능하게 되어 있습니다. 데모나 문서를 참조해서 보세요.

   

  jQuery Tools는 jQuery UI에서 지원해 주지 못하는 있었으면 하는 Widget들을 지원해 줍니다. Tab은 UI 쪽에 있긴 하지만요.

이건 백문이 불여일견입니다. 한 번 데모(http://flowplayer.org/tools/demos/index.html)를 보세요.

   

  jQuery Form은 Form 값을 Ajax로 처리하는 걸 간편하게 해 주는 Library입니다. 처리의 간편함을 위해 사용했습니다. 아쉬운 건 JavaScript Object의 값을 Form의 각 요소에 세팅해 주는 게 있었으면 했는데 없어서 직접 구현했네요.

   

   jquery keyfilter는 Input 필드나 TextArea에서 Key 입력을 제한해 주는 Library입니다. 보통 keydown 이벤트에 keyCode 값을 읽어 true / false를 돌려 주는 식으로 구현을 많이 하는데 역시 이걸 사용하면 간편해집니다.

   

  jquery numberformatter 는 숫자 포매팅해 주는 Library 입니다. Locale 을 적용해서 포매팅 해 주는 게 특징이구요. 패턴을 직접 지정해 줄 수도 있습니다.

   

  UI.Layout 은 BorderLayout을 구현한 건데요. Java에서 AWT, Swing 프로그램이나 델파이 같은 RAD 툴을 써 보신 분은 아실 겁니다. 화면의 영역은 east, west, south, north, center 5가지 영역으로 나누어 놓고, 전체 화면의 크기가 변경될 때 east, west는 지정한 폭을, south, north 는 지정한 높이를 유지시켜 주는 역할을 합니다. 물론 그렇기 때문에 center 영역은 나머지 4개 영역을 제외한 영역으로 꽉 차게 유지가 되는 거죠.

  여기에 동서남북 4개 영역과 center 사이의 경계를 드래그로 조절하게 한다든지 4개 영역을 닫았다 열었다 한다든지 하는 기능들이 들어 있습니다. 웹 프로그램이 Thin Client 역할로 사용되면서 이런 기능들이 요구되고 있는 상황인 거죠.

  이 Layout 이 아쉬운 부분이 jQuery Grid와 연동이 자동으로 안 되고 onresize 이벤트 핸들러를 만들어 처리해 주어야 하는 점이었습니다. 하지만 복합한 코딩을 요구하는 건 아니니까요. 간단히 작성하실 수 있을 겁니다.

   

  그리고 마지막 뽀너스입니다. ^^

  이번 프로젝트에서 써 보지는 않았는데요. 설마 이런 게 JavaScript로 가능하리라고는 생각지 않아서 검색조차 안 해 봤는데 있더라구요. MaskEdit 가 있었습니다.

  델파이나 VB 처럼 자연스럽게 동작하지는 않지만 훌륭하네요. ^^

   

  점점 프로그램이 즐거워지고 있습니다. 그럼 즐프들 되세요. ^^

   

   

'IT > JavaScript' 카테고리의 다른 글

텍스트박스에 숫자만 입력받아보자  (0) 2010.06.07
Posted by 만들고보자
|