'3. Implementation/JSP'에 해당되는 글 6건

  1. 2015.01.15 MVC Execution Flow
  2. 2015.01.15 JavaBeans, POJO, VO and DTO
  3. 2010.09.10 web.xml specification
  4. 2010.09.09 JSP 기술 문서
  5. 2010.07.27 웹 프로젝트 생성하기
  6. 2010.07.27 JSP 개발 환경 구축
2015. 1. 15. 23:24

MVC Execution Flow



Referenced : 열혈강의 자바 웹 개발 워크북

2015. 1. 15. 22:59

JavaBeans, POJO, VO and DTO

JavaBeans


JavaBeans are reusable software components for Java that can be manipulated visually in a builder tool. Practically, they are classes written in the Java programming language conforming to a particular convention. They are used to encapsulate many objects into a single object (the bean), so that they can be passed around as a single bean object instead of as multiple individual objects. A JavaBean is a Java Object that is serializable, has a nullary constructor, and allows access to properties using getter and setter methods.

In order to function as a JavaBean class, an object class must obey certain conventions about method naming, construction, and behavior. These conventions make it possible to have tools that can use, reuse, replace, and connect JavaBeans.

The required conventions are:

  • The class must have a public default constructor. This allows easy instantiation within editing and activation frameworks.
  • The class properties must be accessible using get, set, and other methods (so-called accessor methods and mutator methods), following a standard naming convention. This allows easy automated inspection and updating of bean state within frameworks, many of which include custom editors for various types of properties.
  • The class should be serializable. This allows applications and frameworks to reliably save, store, and restore the bean's state in a fashion that is independent of the VM and platform.

Because these requirements are largely expressed as conventions rather than by implementing interfaces, some developers view JavaBeans as Plain Old Java Objects that follow specific naming 


POJO (Plain Old Java Object)


POJO is an acronym for Plain Old Java Object. The name is used to emphasize that the object in question is an ordinary Java Object, not a special object, and in particular not an Enterprise JavaBean (especially before EJB 3). The term was coined by Martin Fowler, Rebecca Parsons and Josh MacKenzie in September 2000:

"We wondered why people were so against using regular objects in their systems and concluded that it was because simple objects lacked a fancy name. So we gave them one, and it's caught on very nicely."

The term continues the pattern of older terms for technologies that do not use fancy new features, such as POTS (Plain Old Telephone Service) in telephony, and PODS (Plain Old Data Structures) that are defined in C++ but use only C language features, and POD (Plain Old Documentation) in Perl.

The term has most likely gained widespread acceptance because of the need for a common and easily understood term that contrasts with complicated object frameworks. A JavaBean is a POJO that is serializable, has a no-argument constructor, and allows access to properties using getter and setter methods. An Enterprise JavaBean is not a single class but an entire component model (again, EJB 3 reduces the complexity of Enterprise JavaBeans).

As designs using POJOs have become more commonly-used, systems have arisen that give POJOs some of the functionality used in frameworks and more choice about which areas of functionality are actually needed. Hibernate and Spring are examples.


VO (Value Object)


In Patterns of Enterprise Application Architecture I described Value Object as a small object such as a Money or date range object. Their key property is that they follow value semantics rather than reference semantics.

You can usually tell them because their notion of equality isn't based on identity, instead two value objects are equal if all their fields are equal. Although all fields are equal, you don't need to compare all fields if a subset is unique - for example currency codes for currency objects are enough to test equality.

A general heuristic is that value objects should be entirely immutable. If you want to change a value object you should replace the object with a new one and not be allowed to update the values of the value object itself - updatable value objects lead to aliasing problems.

Early J2EE literature used the term value object to describe a different notion, what I call a Data Transfer Object. They have since changed their usage and use the term Transfer Object instead.

You can find some more good material on value objects on the wiki and by Dirk Riehle.


DTO (Data Transfer Object)


Data transfer object (DTO), formerly known as value objects or VO, is a design pattern used to transfer data between software application subsystems. DTOs are often used in conjunction with data access objects to retrieve data from a database.

The difference between data transfer objects and business objects or data access objects is that a DTO does not have any behaviour except for storage and retrieval of its own data (accessors and mutators).

In a traditional EJB architecture, DTOs serve dual purposes: first, they work around the problem that entity beans are not serializable; second, they implicitly define an assembly phase where all data to be used by the view is fetched and marshalled into the DTOs before returning control to the presentation tier.


2010. 9. 10. 05:45

web.xml specification

web.xml 에 관한 스펙문서는 Java Servlet Specification 에 포함되어 있습니다. 사실 스펙문서에도 그냥 DTD 에 대해서만 나와 있습니다. DTD 자체가 문서화로 설명을 기술하는 것이기 때문에 이로 대체하는 것입니다. 따라서, web.xml 의 전체 사양을 알고 싶은 경우는, Java Servlet Specification 의 문서를 참조하거나, 아니면 아래에 나와 있는 dtd 링크를 바로 참조하시면 됩니다. 
또한, dtd 링크는 사용하는 web.xml 에 아래처럼 반드시 선언되어 있기 때문에, 해당하는 버전에 맞는걸 찾아서 참고하시면 됩니다.




각 버전별 DTD 링크 예
Servlet 2.2 (DTD)    : http://java.sun.com/j2ee/dtds/web-app_2_2.dtd
Servlet 2.3 (DTD)    : http://java.sun.com/dtd/web-app_2_3.dtd
Servlet 2.4 (Schema) : http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd
Servlet 2.5 (Schema) : http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd
2010. 9. 9. 05:57

JSP 기술 문서

JavaServer Page 2.1 Expression Lanaguage Specification &
JavaServer Page 2.1 Specification


JSP 1.2, 2.0 

JSP Standard Tag Library Specification 1.0 Final Release


Java Servlet Specification 2.3



2010. 7. 27. 23:29

웹 프로젝트 생성하기

(JEE Helios version)

1. File > New > Dynamic Web Project 선택


Dynamic web module version: JSP 2.1 의 경우 서블릿 2.5, JSP 2.0 의 경우 서블릿 2.4 버전 선택

2. Next 클릭


3. Next 클릭


Context root: 웹 애플리케이션의 콘텍스트 경로를 입력. 이 항목에 입력한 값을 이용해서 http://서버:포트/[콘텍스트경로] 형식의 주소로 접근. 루트('/') 콘텍스트인 경우 값을 입력하지 않는다.

Content directory: JSP, HTML, 이미지, WEB-INF 디렉토리가 위치할 디렉토리의 이름을 입력

Generate web.xml deployment descriptor: web.xml 파일을 생성할지의 여부를 지정

참고: JSP 2.1 웹프로그래밍 - 최범균
2010. 7. 27. 23:17

JSP 개발 환경 구축

 JDK  JDK SE 5.0 이상 설치 
 웹컨테이너  톰캣, 제티, GlassFish 등
 코드 편집기  이클립스 

이클립스 설치 및 실행하기

- 이클립스는 최신 Helios 를 이용하여 설명

다운로드: Eclipse IDE for Java EE Developers (http://www.eclipse.org/downloads/packages/release/helios/r)

Windows > Preference > Server > Runtime Environments



Add 버튼 클릭


Next 클릭 > Tomcat installation directory 지정


Finish 버튼 클릭 > 설정한 서버가 목록에 추가된 것 확인


참고: JSP 2.1 웹 프로그래밍 - 최범균