2010의 게시물 표시

Annotation 기본 설정

 Struts2에서는 Annotation (Java1.5 부터 추가된 클래스나 메서드 위에 @기호와 함께 기재된 문자열로, 메타데이터 기능이다.) 을 사용하여 struts.xml 파일이 없이 직접 mapping하는 방식을 지원한다. 만약 struts.xml에 수행할 action이 없을 경우에 자체적으로 Annotation을 수행하게 된다.  예를 들어 http://localhost:8989/info/list.action  으로 들어온다면 struts.xml에서 먼저 검사를 한다음 수행할 액션이 없을 경우, web.xml의 init-param으로 이동하여 Annotation을 수행하게 된다.  struts.xml을 사용하지 않는다는것은 struts.xml의 actino mapping의 설정을 사용하지 않는 다는 것이고,(struts.xml 있어도 되고, 없어도 되는 옵션이된다는 뜻!) <struts>    <!-- include files -->    <include file="info.xml"/><!-- 사용하지 못한다. --> </struts>   그렇기 때문에 Annotation을 사용한다는 것을 알려줘한다. 그러기 위해서 web.xml에 반드시 설정해줘야 된다. 그리고 Annotation을 사용하면 무조건 default인 ***.action 만 가지고 들어와야 한다.(properties에 설정한 *.do, *.etc등은 안된다.)  또한, action class의 이름은 list.action을 호출하면 ListAction이 되어야 한다. 즉 list.action => list + action = ListAction 이 되야한다. 이렇게 설정해 주어야만 struts2에서 자동으로 mapping을 해준다. ■ 설정 1. web.xml에서 FilterDispatcher의 파라메터를 설정한다.  <ini...

Struts2 기본 환경 설정 및 구현

이미지
기본 환경 설정. 1. library 파일 추가.   apache 사이트의 struts 에서 다운로드. 여기서는 2.0.14 버전을 사용한다. 공부용으로 사용하기 위해 Full Distribution을 다운로드 한다.  다운로드한 파일에서 struts-2.0.14\apps\ 들어가면 struts2-blank-2.0.14.war 파일이 존재 한다. 이 파일은 예제파일로 이것을 기본으로 작업을 수행 할 수 있도록 제동된 파일이다. 이것을 압출해제 하면 struts2-blank-2.0.14\WEB-INF\lib 안에 들어있는 파일 들을 eclipse에서 생성한 프로젝트의 lib 폴더에 복사해서 사용한다. 2. web.xml 파일 설정  <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> * filter-name은 위에서 설정한 filter-name과 같아야 한다. url-pattern에는 다른 확장자를 사용할 수 없으면 /*가 default다. 다른 확장자는 struts.properties에서 설정 할 수 있다. 3. struts.properites 파일 생성  메모장을 사용하여 struts.properites 파일을 만들고 eclipse의 na...

Struts2의 작동 원리

이미지
Struts2의 작동 원리  Struts2 Framework Architecture Diagram  1. Client가 HttpServletRequest를 요청하면 FrontController인 FilterDispatcher가 받는다.  2. ActionMapper부터 ActionProxy 등을 거쳐 와서 Config 문서인 struts.xml 문서와 추가로 struts.properties 파일을 요구한다. struts.properties는 있으면 로딩하고 없으면 하지 않는다.(없어도 된다)  3. struts.xml과 strtus.properties문서를  Interceptor가 받아온다. 그리고 Client의 모든 Parameter를 가로챈다.  4. Interceptor 은 3단계로 나누어져 있다. 1단계에서는 Client의 모든 Paramter를 가로챈다. 2단계에서는 렌더링 역할을 수행한다.(언어 설정, 보안 설정 등) 3단계에서는 Action의 setter method 를 찾고, 데이터를 푸시하는 역할을 한다.(ActionForm이 필요없다)  5. Business Logic Controller인 Action에서 setter method 메소드를 받아서 비즈니스로직을 수행한다.  6. getter method를 통해 Result로 전달해주거나 받는다. Result에서 적절한 페이지를 선택한다. 이때 Template를 지정한다.(JSP, JSF, Velocity(확장자 : vm), FreeMarker(확장자 : ftl)) 적정할 Template를 잡아서 다시 Interceptor로 보낸다.(getter를 통해서 객체는 머든 상관없다)  7. 다시 역방향으로 간다. 1단계에서 Result에서 적절한 페이지를 선택할때, 그 페이지를 찾는다. 그리고 그 페이지의 Value Stack( 그림에는 없음 )을 갖고, Value Stack에다가 데이터를 넣주고 그냥 찍기만 하면 된다...

Struts 2 는 무엇인가 ?

이미지
Struts 2 는 무엇인가?  WebWork + Struts 가 합쳐진게 Struts 2 이다. http://struts.apache.org/  WebWork는 View Framework 로서 유명하고, 이를 기반으로 WebWork Framework와 Struts Framework가 합쳐져 Struts 2가 탄생.  Struts 1과 Struts 2는 다르며, 그 이유중 하나는 WebWork의 인터셉터 (Interceptor)라는 개념이 들어가 있다.   인터셉터는 HttpRequest를 중간에서 가로채는 Filter와 비슷한 개념이나, Action 전 후에 다른 처리를 할 수 있다. 인터셉터는 AOP(aspect-oriented programming) 개념으로 생각하면 된다고 한다.  그외에 의존성주입(Dependency Injection)을 지원하고, 다양한 Plugin(JFreeChard, Sitemesh 등), Result 타입을 지원한다. http://thinkingblog.tistory.com/7  생각하는 블로그 bnk  

java class loader 에 대하여

이글은 http://www.artima.com/insidejvm/ed2/jvm4.html  이곳에 있는것을 그냥 알고싶어서 적어본다   the Java virtual machine contains two kinds of class loaders: 자바 가상머신에는 두가지의 클래스 로더가 포함되어 있다 a bootstrap class loader 하나는 부트스트랩 로더 and user-defined class loaders. 또 하나는 유저정의 클래스 로더 The bootstrap class loader is a part of the virtual machine implementation, 부트스트랩 클래스 로더는 가상머신의 구현부분의 일부분이다 and user-defined class loaders 그리고 유저정의 클래스 로더는 are part of the running Java application. 실행되는 자바 프로그램의 일부이다 (즉 Java Application 의 일부에 포함한다고 볼수있다) Classes loaded by different class loaders 클래스 로드는 다른 클래스 로더에 의해 자바 버추얼 머신의 네임스페이스로 분리된공간에 로드된다 are placed into separate name spaces inside the Java virtual machine.   The class loader subsystem involves many other parts of the Java virtual machine and several classes from the java.lang library. For example, user-defined class loaders are regular Java objects whose class descends from java.lang.ClassLoader . The methods of class ClassLoader allo...

Elcipse 3.6 Spring IDE Plug in 설치시 에러 문제

Error Message : Missing requirement: Spring IDE AJDT Integration   Elcipse Help - Install New Software   Add Button - Click   Name : 아무거나 허지만 알아봐야 겠지 .. AJDT Update AspectJ Developemtn Tools Location : http://download.eclipse.org/tools/ajdt/36/update    36 - Eclipse versio Helios   Check install : AspectJ Development Tools (Required)           필수설치   이후에 Spring IDE Option 설치 하면 된다 -- 여기저기 뒤져서 찾아서 적어놓은것      

Struts 사용시 경고 메시지 Server/Service/Engine/Host/Context 처리

-Tomcat6.0버전을 처음 사용해 보면서, 문제가 발생했다. 출처의 아티클을 보면 알겠지만, Tomcat 6.0부터 지원하는 source라는 Attribute 때문에 일어나는 문제라고 한다.   Warning :  [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source'     to  'org.eclipse.jst.j2ee.server:demo' did not find a matching property   Solution : Server's Properties -> General -> Location = /Servers/Tomcat v6.0 Server at localhost.server; Project Explorer -> Servers -> Tomcat v6.0 Server at localhost.server, double click to open it. Server Options -> Check " Publish module contexts to separate XML files ". Explaination : Tomcat of previous version doesn't support the "source" attribute in the "Context" node of "server.xml" file. Result : A separate XML file named "demo.xml" was created in the "$server path$\conf\Catalina\localhost\". Reference : http://www.ibm.com/developerworks/opensource/library/os-eclipse-...

Spring

Spring IoC (Inversion of Control)  콘트롤 전도(반전)  역전 EJB  (Enterprise javaBean)  Container 에 의존하는 객체 (복잡하고 개발자가 쓰기 어렵다는것?) POJO ( Plain Old java Object) 자바개발자가 마음대로 정의 할수 있는 객체,  Object 를 간단히 수퍼클래스로 둔 보통의         평법의 순수 자바 클래스라고 볼수 있다고 한다. POJO 의 필수 요소 - Light-weight (possibly) : 가볍게 - Flexible : 유연성 - Simple : 간단 명료 - Supported by Separate optional compnents such as hibernate or Spring - 즉 , Spring , Hibernate, Ibatis 등에서 객체를 가볍게, 간단히 유연하게 어떤 Object 에 대해 추상화 할수 있는 객체를 만들어야 한다. AOP (Aspect Oriented Programming  ) 관점지향 프로그래밍 Aspect : 양상,관점,모습,면,방향,방면,용모,외양,방위,상,별의 상             ex) a mountain with a beatiful aspect : 모습이 아름다운 산                  consider a question in all its aspects (from every aspedt)  문제를 모든 각도에서 고찰하다. Avalon : 은 영국(United Kingdom Of Great britain and Northern Ireland)의 어디엔가에 있었다고 여겨지는 전설상의 섬이다.         ...

Spring Dynamic Modules for OSGi(tm) Runtimes 배우기

OSGi =  Open Service Gateway initiative Alliance 는 1999년에 Sun Microsystems ,IBM, Ericsson 등이 구성한             개방형 표준 단체이다. 자세한것은 위키 백과 http://ko.wikipedia.org/wiki/OSGi  참고바람. 처음에는 Connected Alliance 라고 불렸다고 한다. 이 표준 사양의 핵심은 Application Program 의 Life cycle 은 Model and Service Registry 를 정의 하는 Framework 이다. OSGi Framework 은 독립적인 Jave / Virtual Machine 환경에서 제공하고 있지 못한 세련되고, 완전하며 동적인 Component Model 을 구현한다. 응용프로그램 또는 구성요소(번들,Bundle) 는 다시 시동과정 없이 원격지를 통해 Installed,Stated ,Stoped,Updated and Uninstalled 할수있다. OSGi 는 Embeddable( Appplication 내보로 포함될수있는) SOA 를 구현하고 있다. SOA = Service Oriented Architecture (서비스 지향 아키텍처) , Service , Message 로 구성. Web service based SOA 가 네트워크를 중심으로 하는 SOA 라면 OSGi 는 Java Object based SOA 이다.                     Initiative : (명) 발의,초보,의안제출권,기업심,선제,선창,주도(권) ,독창력,창업의 재간, 국민발안,의안 제출권 Component : (명) 구성요소 (형) 구성하고 있는

유투브 동영상 섬네일 가져오기

유투브( youtube )의 동영상 썸네일이 필요할 때가 있습니다. 물론 유투브 개발자센터 에 유투브 API활용에 대한 친절하고도 자세한 설명이 나와있지만, 죄다 영문에 상당히 읽기 빡빡한 문서입니다. 혹시 다른건 다 필요없고 유투브에서 동영상 썸네일만 필요하신 분들을 위한 팁. 유투브의 동영상은 해당 페이지의 고유한 주소가 있습니다. http://www.youtube.com/watch?v=2hTRAVIXjX8 http://www.youtube.com/watch?v=OgyVGamz_Kk http://www.youtube.com/watch?v=qj4grv8qFoQ v= 다음에 나오는 영문과 숫자의 조합이 바로 동영상에 대한 id값입니다. 바로 이 id값만 알면 해당 동영상의 썸네일 이미지를 가져올수 있습니다. http://img.youtube.com/vi/2hTRAVIXjX8/2.jpg http://img.youtube.com/vi/OgyVGamz_Kk/2.jpg http://img.youtube.com/vi/qj4grv8qFoQ/2.jpg http://img.youtube.com/vi/동영상id/2.jpg 바로 이러한 형식으로 url을 요청하면 해당 동영상의 120*90의 썸네일 이미지를 가져올 수 있습니다. 한개의 동영상에는 3개의 썸네일 이미지가 등록되어있고 파일이름은 각각 1.jpg, 2.jpg, 3.jpg 입니다. 동영상주소 : http://www.youtube.com/watch?v=2hTRAVIXjX8 썸네일주소 : http://img.youtube.com/vi/2hTRAVIXjX8/2.jpg 썸네일이미지

Thumbnail Generator

    /*   *   * Part of the InfoGlue Content Management Platform (www.infoglue.org)   *   *   *   *  Copyright (C)   *   * This program is free software; you can redistribute it and/or modify it under   * the terms of the GNU General Public License version 2, as published by the   * Free Software Foundation. See the file LICENSE.html for more information.   *   * This program is distributed in the hope that it will be useful, but WITHOUT   * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS   * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.   *   * You should have received a copy of the GNU General Public License along with   * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple   * Place, Suite 330 / Boston, MA 02111-1307 / USA.   *   *   */ import java.awt.*; im...

iframe content remove

document.testIframe.document.body.innerHTML=""

Java Enumeration is a raw type. References to generic type Enumeration<E> should be parameterized

Enumeration is a raw type. References to generic type Enumeration<E> should be   parameterized forum.sun.com -------------------------------------------------------------------------------------------- Hi, I am getting a compilation warning at the statement Enumeration<String> params = (Enumeration<String>)request.getParameterNames(); I am facing problem in removing this warning. I don't want to use @SuppressWarnings("unchecked") Can anyone please help in removing this warning? --------------------------------------------------------------------------------------------- I see two options. The first is to change request.getParameterNames() to return Enumeration<String> instead of Enumberation assuming that getParameterNames always returns Strings. The other is to use a wild card enumeration instead of a Enumeration<String>. Since all objects can be converted to Strings it will allow you to use the Enumeration without getting any class ...

frame 이동

1. 자식창에서 부모창의 특정 Form 에 데이터를 집어넣고 싶을 때   자식창에서 부모창을 가리킬 때 opener 객체를 사용한다 . document.Form.input 은 부모창에   속해있는 요소이다 . ( 자바스크립트 함수 호출 도 opener를 사용하면 된다 !)   opener .document.Form.input.value = “ 값 ”;       2. 자식창에서 부모창의 페이지를 이동시키고 싶을 때   부모창을 원하는 페이지로 이동시킨후 자식창 ( 자기자신 ) 은 닫는다 .   window.opener.location.href = “/admin/login.jsp” ;   window.close();     3. 자식창에서 부모창을 새로고침하고 싶을 때   if (!opener.closed){   opener.document.location.reload();   window.close();   }     4. iframe 내부에서 외부에 있는 메인페이지의 특정 Form 에 값을 집어넣고 싶을 때   iframe 에서 메인을 가리킬때는 parent 객체로 접근한다 . ( 자바스크립트 함수 호출 도 parent를 사용하면 된다 !)   parent.Form.input.value = “ 값 ”;     5. iframe 내부에서 외부에 있는 메인페이지의 스크립트 함수를 실행하고자 할 때   parent.[ 메인함수명 ]   parent.DoSend();       6. 메인에서 iframe 의 페이지를 이동시키고 싶을 때 ...

Image Thumbnail

<%@ page language="java" contentType="text/html; charset=EUC-KR"     pageEncoding="EUC-KR"%>     <%@ page import="java.io.* "%> <%@ page import="java.io.File" %> <%@ page import="java.awt.Image , java.awt.image.BufferedImage" %>    <%@ page import="java.util.*"%> <%@ page import="javax.imageio.ImageIO" %> <%@ page import="java.awt.Graphics2D" %> <%@ page import="java.awt.Graphics2D" %> <!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> <%             //String files = application.                     String file = application.getRealPath("./");           ...

image Thumbnal Make

이 요약은 사용할 수 없습니다. 이 글을 보려면 여기를 클릭하세요.

jsp cos.jar multipart file Upload

cos.jar => 파일 업로드와 enctype="multipart/form-data"로 넘겨져 오는 파라미터에 대한 이름과 값을 얻어낼 수 있다.   2. 1) testController에서 MultipartRequest를 사용하기 위해서 com.oreilly.servlet 패키지를 import 해야한다. ex.import com.oreilly.servlet.*;   2) MultipartRequest는 객체를 생성하자마자 파일을 업로드시킨다. ex. MultipartRequest multi = new MultipartRequest(request, "파일저장경로(String)", 파일크기(int), "인코딩"); 3) MultipartRequest를 사용하게되면 톰캣의 request 객체의 getParameter 메소드를 이용하여 값을 전달받지 못한다. 따라서 MultipartRequest를 사용하게 되면 값을 전달받기 위해서는 MultipartRequest 객체의 getParameter 메소드를 이용하여 값을 전달받아야 한다. ex. String user = multi.getParameter("user"); 4) 파일을 저장할 경로는 톰캣의 내장객체인 application.getRealPath() 메소드를 사용한다. ex. String fileSave = application.getRealPath("fileSave"); MultipartRequest multi = new MultipartRequest(request, fileSave); 5) 전송한 파일 정보를 가져온다. ex. Enumeration file = multi.getFileNames(); while(files.hasMoreElements()){ // 파일 정보가 있다면     String name = (String)files.nextElement(); //...

Flex & jsp interface

<%@ page language="java" contentType="text/html; charset=UTF-8"     pageEncoding="UTF-8"%> <%  request.setCharacterEncoding("UTF-8"); %> <%@ page language = "java" %> <%@ page import   = "java.util.* , java.lang.* " %> <%@ page import   = "javax.servlet.http.*" %> <%@ page import   = "java.sql.Connection , java.sql.DriverManager , java.sql.SQLException" %> <%@ page import   = "java.sql.* " %>   <%   Statement stmt = null;   ResultSet rs = null;      String url = "jdbc:mysql://localhost:3306/데이터베이스 명";      Class.forName("com.mysql.jdbc.Driver");      Connection conn = DriverManager.getConnection(url,"SQL USER ID","SQL PASSWORD");         // Parameter Get    String command = request.getParameter ("command");    String userid = request.getParameter ("userid");     String username ...

Tomcat 한글문제 ..

Remember ...my brain clean ------------------tomcat server.xml---------------------  <Connector port="8080" protocol="HTTP/1.1"                connectionTimeout="20000"                redirectPort="8443"                useBodyEncodingForURI="true"    /> -----------------------------------------------------  <Connector port="8080" protocol="HTTP/1.1"                connectionTimeout="20000"                redirectPort="8443"                URIEncoding ="euc-kr">    /> ----------------------------------------------- 둘중에 어떤것이 좋을지는 ?   jsp 나 프로그램에서 . 설정하는 charencoding  지정으로 하려면 위에것으로 하면 되고 밑에것에 정의된것을 tomcat 에 의존하는 방법이다 ..   jsp code 예)   <% request.setChara...

JSP 한글 Remember

Remember -- Brain   Apache Tomcat 설치 Directory 보통 설치 디렉토리가 .. 있다면 C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\examples\WEB-INF\classes\filters  (examples) 를 설치 하지 않았으면 찾아서 같이 설치해주고 .. 필터 클래스는 이곳에 있으니 카피 하면 된다 . class 홀더 생성하고 .. 그곳에 카피 SetCharacterEncodingFilter.class Project 홀더 밑에 .. WEB-INF\classes\filters     jsp 프로그램시 web.xml 에 Filter 를 추가해주는 방식으로 처리하는것이 깔끔하게 정리가 잘되는것 같다 -----------------------Project file web.xml ---------------------------------------------- <?xml version = "1.0" encoding = "utf-8"?> <web-app ----          추가하여야 할부분 ...         <filter>       <filter-name>CharsetFilter</filter-name>       <filter-class>filters.SetCharacterEncodingFilter</filter-class>         <init-param>           <param-name>encoding</pa...

한글깨짐현상

mysql version : mysql server 5.1   default mysql setting - 이부분이 기본적으로 생각없이 설치 하면 .. 기본값으로 요렇게 들어간다   --my.ini-------------------- [mysql] default-character-set=latin1 [mysqld] default-character-set=latin1 ---------------------------   mysql 설치 디렉토리에서  예) C:\Program Files\MySQL\MySQL Server 5.1 이곳에 있는 my.ini --my.ini-------------------- [mysql] default-character-set=euckr   [mysqld] default-character-set=euckr ------------------------------------------------------------------------------------ 이렇게 바꾸어주고  Save 한후 mysql - restart 또는 Stop -> Start   ==테이블 생성 시 character set이 euckr로 되어있지 않았다면 테이블의 character set을 euckr로 변경해줘야 한다.   mysql>Alter table [데이블명] convert to character set euckr;   mysql을 재시작 후 확인   ------------------------------------------------------------------------------------ Flex Builder 를 이용하여 Flex  를 사용할때는 utf-8 를 기본으로 설정하여 사용할것을 권고 .. ------------------------...

기본정리 - JDBC Connect

Driver Type :  MySQL JDBC Driver Driver Name : Mysql JDBC Driver Jar List : mysql-connector-java-5.1.13-bin.jar Connection URL : jdbc:mysql://localhost:3306/database   /특정 데이터베이스에서 조건 검색을 할때 SELECT * FROM `test`.`pet` where sex ='f'; SELECT * FROM `TEST`.`PET`;  `TEST`,`PET` 에서 모든 데이터 가져오기   (테스트데이터베이스의 PET 테이블에서) SELECT * FROM PET;  PET 테이블의 모든데이터 가져오기 SELECT * FROM `TEST`.`PET` WHERE NAME = 'BUFFY';  TEST 데이터 베이스의 PET 테이블에서 NAME 항목의 BUFFY 이름만 가져오기 SELECT * FROM `TEST`.`PET` WHERE SEX = 'M';  TEST 데이터 베이스의 PET 테이블에서 SEX 항목중 'M' 을 모두 가져오기 SELECT * FROM `TEST`.`PET` WHERE  BIRTH >= '1998-1-1';  TEST 데이터 베이스의 PET 테이블에서 BIRTH 가 1998-1-1 보다 크거나 같은 데이터 모두 가져오기 SELECT * FROM PET WHERE SPECIES = 'DOG' AND SEX = 'M';   PET 테이블에서 SPECIES 가 'DOG' 이며 'SEX' 가 'M' 인 데이터 모드 가져오기 AND 와 OR 를 혼용하여 사용할수 있으나 AND 가 OR 보다 우선 순위가 높다 . 이 두가지 연산자를  모두 사용할 경우에는, 어떤 조건문이 그룹으로 동작되어야 하는지를지정하기 위해 괼호를 사용하는 것이좋다 . SE...