[Spring MVC] References

JAVA 2015. 7. 10. 14:47

http://www.tutorialspoint.com/spring/spring_overview.htm


http://docs.spring.io/docs/Spring-MVC-step-by-step/

https://youtu.be/iCQspqBpOB0

Posted by 라딘.

댓글을 달아 주세요

자바 웹 어플리케이션에 대해서 매우 정리가 잘 되어 있는 글이다.


여러분은 자바 웹 애플리케이션 서버에 대해 얼마나 알고 계신가요?



추가로 서블릿에 대해서도 함께 정리해 보면,

  • Servlet

Servlets are server side components that provide a powerful
mechanism for developing server side programs. Servlets
provide component-based, platform-independent methods for
building Web-based applications, without the performance
limitations of CGI programs. Unlike proprietary server
extension mechanisms (such as the Netscape Server
API or Apache modules), servlets are server as well as
platform-independent. This leaves you free to select a "best
of breed" strategy for your servers, platforms, and tools.
Using servlets web developers
can create fast and efficient server side application
which can run on any servlet enabled web server. Servlets
run entirely inside the Java Virtual Machine. Since the
Servlet runs at server side so it does not checks the
browser for compatibility. Servlets can access the entire
family of Java APIs, including the JDBC API to access
enterprise databases. Servlets can also access a library of
HTTP-specific calls, receive all the benefits of the mature
java language including portability, performance,
reusability, and crash protection. Today servlets are the
popular choice for building interactive web applications.
Third-party servlet containers are available for Apache Web
Server, Microsoft IIS, and others. Servlet containers are
usually the components of web and application servers, such
as BEA WebLogic Application Server, IBM WebSphere, Sun Java
System Web Server, Sun Java System Application Server and
others.

Servlets are not designed for a specific protocols. It is
different thing that they are most commonly used with the
HTTP protocols Servlets uses the classes in the java
packages javax.servlet and javax.servlet.http. Servlets
provides a way of creating the sophisticated server side
extensions in a server as they follow the standard framework
and use the highly portable java language.

source: http://www.allinterview.com/showanswers/4911/what-is-servlet-and-what-you-get-when-we-use-servlets.html


general definition of Servlet from Wikipedia

  • performance limitations of CGI programs.

http://help.websiteos.com/support/limitations_on_cgi_scripts.htm

http://www.hinduwebsite.com/webresources/cgiscripts.asp


  • JSP vs Servlet

      View 가 필요없는 서비스일 경우엔 바로 Servlet으로 구현하고, View 가 필요한 서비스일 경우엔 JSP 를 활용.


       reference : Performance Comparison of Alternative Solutions For Web-To-Database Applications


Posted by 라딘.

댓글을 달아 주세요

  1. 먹튀 검증 2018.07.23 06:35 신고  댓글주소  수정/삭제  댓글쓰기

    잘보고갑니다

Source: 

https://stackoverflow.com/questions/1913098/what-is-the-difference-between-an-interface-and-abstract-class



Interfaces

An interface is a contract: the guy writing the interface says, "hey, I accept things looking that way", and the guy using the interface says "OK, the class I write looks that way".

An interface is an empty shell, there are only the signatures (name / params / return type) of the methods. The methods do not contain anything. The interface can't do anything. It's just a pattern.

E.G (pseudo code):

// I say all motor vehicles should look like this:
interface MotorVehicle
{
    void run();

    int getFuel();
}

// my team mate complies and writes vehicle looking that way
class Car implements MotorVehicle
{

    int fuel;

    void run()
    {
        print("Wrroooooooom");
    }


    int getFuel()
    {
        return this.fuel;
    }
}

Implementing an interface consumes very little CPU, because it's not a class, just a bunch of names, and therefore there is no expensive look-up to do. It's great when it matters such as in embedded devices.

Abstract classes

Abstract classes, unlike interfaces, are classes. They are more expensive to use because there is a look-up to do when you inherit from them.

Abstract classes look a lot like interfaces, but they have something more : you can define a behavior for them. It's more about a guy saying, "these classes should look like that, and they have that in common, so fill in the blanks!".

e.g:

// I say all motor vehicles should look like this :
abstract class MotorVehicle
{

    int fuel;

    // they ALL have fuel, so why not let others implement this?
    // let's make it for everybody
    int getFuel()
    {
         return this.fuel;
    }

    // that can be very different, force them to provide their
    // implementation
    abstract void run();


}

// my team mate complies and writes vehicle looking that way
class Car extends MotorVehicle
{
    void run()
    {
        print("Wrroooooooom");
    }
}

Implementation

While abstract classes and interfaces are supposed to be different concepts, the implementations make that statement sometimes untrue. Sometimes, they are not even what you think they are.

In Java, this rule is strongly enforced, while in PHP, interfaces are abstract classes with no method declared.

In Python, abstract classes are more a programming trick you can get from the ABC module and is actually using metaclasses, and therefore classes. And interfaces are more related to duck typing in this language and it's a mix between conventions and special methods that call descriptors (the __method__ methods).

As usual with programming, there is theory, practice, and practice in another language :-)




---------------------------------------------------------------------------------------------------------------

The key technical differences between an abstract class and an interface are:

  • Abstract classes can have constants, members, method stubs and defined methods, whereas interfaces can only have consts and methods stubs.
  • Methods and members of an abstract class can be defined with any visibility, whereas all methods of an interface must be defined as public.
  • When inheriting an abstract class, a concrete child class must define the abstract methods, whereas an an abstract class can extend another abstract class and abstract methods from the parent class don't have to be defined.
  • Similarly, an interface extending another interface is not responsible for implementing methods from the parent interface. This is because interfaces cannot define any implementation.
  • A child class can only extend a single abstract (or any other) class, whereas an interface can extend or a class can implement multiple other interfaces.
  • A child class can define abstract methods with the same or less restrictive visibility, whereas a class implementing an interface must define the methods with the exact same visibility.


Posted by 라딘.

댓글을 달아 주세요

When a programmer executes the following make from README file, he may have a compile error related on 'size_t' of 


    "cd ../libfree  # continue building the basic library

    make "



Solution : Refer this site.

  (replace size_t with socklen_t)

  Then you execute 'make' without other error.

Posted by 라딘.

댓글을 달아 주세요

Eclipse 는 no package structure Jar 안에 있는 class 를 읽을 수 없다.

이 경우, 해당 jar 를 classpath에 설정한 후, default package 안에 class를 만들어서 호출하면 사용 가능.

Posted by 라딘.

댓글을 달아 주세요

java classpath 관련.

JAVA 2011. 2. 16. 15:24

cmd 콘솔에서 Java Package 를 직접 컴파일하고 실행할 때 어느 위치에서 해야하는지 정리해 보았습니다.
항상 Eclipse같은 IDE에서만 실행했더니, 막상 cmd에서 할 땐 많이 햇갈리네요.
4번째 수정, 더 이상 수정할 일 없기를...

-4th-------------------------------------------------------------------------------------------

C:\SourceCodes\src\                        ← compile, run 위치

                      └algo                        ← (pacakge)

                           └rbtree                     ← Source file, Dependency 위치 (pacakge)


Compile : 

C:\SourceCodes\src\javac -classpath .\algo\rbtree; -d .  .\algo\rbtree\RedBlackBST.java

Run : 

C:\SourceCodes\src\java -classpath .\algo\rbtree; algo.rbtree.RedBlackBST < .\algo\rbtree\tinyST.txt

http://www.jitendrazaa.com/blog/java/compile-and-run-java-program-in-package-from-command-line/

-3rd-------------------------------------------------------------------------------------------

D:\ProjectFolder\
               └bin\                        ← class 파일 위치(명령어 실행 위치)
               └src\                        ← compile 위치
                   └Main.java
                   └lib\
                       └ojdbc14.jar
                       └etc.jar
                    └vo\
                    └util\

폴더       : ProjectFolder, src(package 아님), lib
package : vo, util

compile :
D:\ProjectFolder\src\javac -classpath .;lib\etc.jar;ojdbc14.jar; -d ../bin Main.java

실행 :
D:\ProjectFolder\src\bin>java -classpath .;lib\etc.jar;ojdbc14.jar; Main

-2nd--------------------------------------------------------------------------------
파일 위치 및 명령어 실행 위치 현황
D:\Java_EXE \

└Genealogy2 \                     ←명령어 실행 위치

└data
└lib                          ← swt.jar 위치
└META-INF
└src \                      ← 실행 파일 위치

 

실행 명령어
     "C:\Program Files\Java\jdk1.5.0_14\bin\"java -classpath lib\swt.jar; src/ManageGenealogy

-1st---------------------------------------------------------------------------------
cmd 콘솔에서 package를 컴파일하고 실행할 때.
d:\PackageTest\         ← 컴파일 및 명령어 실행위치

└Util                ← PackageTest.java 위치

 


컴파일 명령 : javac -d . PackageTest.java

실행 명령    : java Util/PackageTest

Posted by 라딘.

댓글을 달아 주세요

EXCEPTION
        WHEN exception명1    [OR    exception명2...] THEN
                문장1;
                문장2; ...
        [WHEN    exception명3 [OR exception명4...]    THEN
                문장1;
                문장2; ...]
        [WHEN    OTHERS THEN
                문장1;
                문장2; ...]

- WHEN OTHERS 구문은 EXCEPTION 처리의 마지막 구문으로서 미리 선언되지 못한 모든 경우의 EXCEPTION 처리를 가능하게 합니다.

- EXCEPTION Keyword에 의해 Error처리가 시작됩니다.

- EXCEPTION 처리구문이 필요하지 않으면 생략할 수 있습니다.

=========================================================================================

Predefined    EXCEPTION

DECLARE Section에서 선언할 필요가 없습니다.

Oracle Server 에러 중에서 자주 발생되는 20가지 에러에 대해 미리 정의되어 있는 EXCEPTION입니다.

해당 EXCEPTION 처리 루틴에서 미리 정의된 EXCEPTION 명을 참조하여 에러를 처리합니다.
Predefined EXCEPTION의 종류에는 다음과 같은 것들이 있습니다.

   EXCEPTION명                 에러번호        설  명
- NO_DATA_FOUND            ORA-01403     데이터를 반환하지 않은 SELECT문
- TOO_MANY_ROWS           ORA-01422     두 개 이상을 반환한 SELECT문
- INVALID_CURSOR             ORA-01001     잘못된 CURSOR 연산 발생
- ZERO_DIVIDE                   ORA-01476     0으로 나누기
- DUP_VAL_ON_INDEX         ORA-00001     UNIQUE COLUMN에 중복된 값을 입력할 때
- CURSOR_ALREADY_OPEN ORA-06511    이미 열러 있는 커서를 여는 경우
- INVALID_NUMBER             ORA-01722    문자열을 숫자로 전환하지 못한 경우
- LOGIN_DENIED                 ORA-01017    유효하지 않은 사용자로 LOGON 시도
- NOT_LOGGED_ON            ORA-01012    PL/SQL 프로그램이 오라클에 연결되지 않은 상태에서 호출
- PROGRAM_ERROR            ORA-06501    PL/SQL 내부에 오류
- STORAGE_ERROR             ORA-06500    PL/SQL에 메모리 부족
- TIMEOUT_ON_RESOURCE ORA-00051    오라클이 자원을 기다리는 동안 시간 초과 발생
- VALUE_ERROR                  ORA-06502    산술, 절단 등에서 크기가 다른 오류 발생
- NOT_FOUND                                         ?
Posted by 라딘.

댓글을 달아 주세요

뉴욕의 프로그래머... 란 책을 보다가 거기서 나온 Exception 중 생소한 Concurrent Exception 이 나와서
이걸 한 번 찾아봐야겠다는 생각을 하다가 일부 유명한 Exception을 정리해 본다.

Exception Handling이란 글에서 Exception은 아래 질문에 답할 수 있어서 Debuging에 효과적이라고 한다.
염두에 두어야 겠다.
  • What went wrong?
  • Where did it go wrong?
  • Why did it go wrong?
When exceptions are used effectively, what is answered by the type of exception thrown, where is answered by the exception stack trace, and why is answered by the exception message.

For this, there are three rules.
These rules are: be specific, throw early, and catch late.



Excetption 구조

Exception

Sub Exception Class which extends Exception
AclNotFoundException, ActivationException, AlreadyBoundException, ApplicationException, AWTException, BackingStoreException, BadAttributeValueExpException, BadBinaryOpValueExpException, BadLocationException, BadStringOperationException, BrokenBarrierException, CertificateException, ClassNotFoundException, CloneNotSupportedException, DataFormatException, DatatypeConfigurationException, DestroyFailedException, ExecutionException, ExpandVetoException, FontFormatException, GeneralSecurityException, GSSException, IllegalAccessException, IllegalClassFormatException, InstantiationException, InterruptedException, IntrospectionException, InvalidApplicationException, InvalidMidiDataException, InvalidPreferencesFormatException, InvalidTargetObjectTypeException, InvocationTargetException, IOException, JMException, LastOwnerException, LineUnavailableException, MidiUnavailableException, MimeTypeParseException, NamingException, NoninvertibleTransformException, NoSuchFieldException, NoSuchMethodException, NotBoundException, NotOwnerException, ParseException, ParserConfigurationException, PrinterException, PrintException, PrivilegedActionException, PropertyVetoException, RefreshFailedException, RemarshalException, RuntimeException, SAXException, ServerNotActiveException, SQLException, TimeoutException, TooManyListenersException, TransformerException, UnmodifiableClassException, UnsupportedAudioFileException, UnsupportedCallbackException, UnsupportedFlavorException, UnsupportedLookAndFeelException, URISyntaxException, UserException, XAException, XMLParseException, XPathException


RuntimeException

Sub Exception extends RuntimeException
AnnotationTypeMismatchException, ArithmeticException, ArrayStoreException, BufferOverflowException, BufferUnderflowException, CannotRedoException, CannotUndoException, ClassCastException, CMMException, ConcurrentModificationException, DOMException, EmptyStackException, EnumConstantNotPresentException, EventException, IllegalArgumentException, IllegalMonitorStateException, IllegalPathStateException, IllegalStateException, ImagingOpException, IncompleteAnnotationException, IndexOutOfBoundsException, JMRuntimeException, LSException, MalformedParameterizedTypeException, MissingResourceException, NegativeArraySizeException, NoSuchElementException, NullPointerException, ProfileDataException, ProviderException, RasterFormatException, RejectedExecutionException, SecurityException, SystemException, TypeNotPresentException, UndeclaredThrowableException, UnmodifiableSetException, UnsupportedOperationException


ClassNotFoundException
IOException
RuntimeException
SQLException


ClassCastException
ConcurrentModificationException
IndexOutOfBoundsException
NullPointerException

Posted by 라딘.

댓글을 달아 주세요

  1. 해피씨커 2010.11.22 19:18  댓글주소  수정/삭제  댓글쓰기

    안그래도 최근에 이거 관련된 문서 몇개 봤는뎅 ㅎㅎ

    여기
    http://techvivek.wordpress.com/2009/08/29/difference-between-arraylist-and-copyonwritearraylist/

    가보면 ConcurrentModificationException 쉽게 알수 있다능.

  2. 라딘. 2010.11.24 08:51 신고  댓글주소  수정/삭제  댓글쓰기

    오~ 오랜만이십니다 ㅋ
    잘 계시지요^^?
    간만에 블로그 포스팅을 시작하는데 이거 여전히 어렵네요 ~

String Class의 replaceAll 메서드를 사용할 경우 '$' 로 인해 java.lang.IllegalArgumentException 가 발생할 수 있다. replaceAll 내부에서 matcher 를 사용하기 때문인 듯 하며 해결 방안은
replaceAll을 통해 원하는 메세지로 변경하기 전에 먼저 아래 굵은 글씨 부분을 처리한다.


public class StringTest3 {

    public StringTest3() {}
    
    public void replaceAll2(String str) {
        try {
            String message = "My title is This, 'This is test for String.replaceAll()'.";
            String result = message.replaceAll("title", str);
            System.out.println(result);
        } catch( Exception e ) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        StringTest3 st = new StringTest3();
        String text = "USD mark$";
        String convertedText = text.replaceAll("[\\$]", "\\\\\\$");
        st.replaceAll2(convertedText);
    }

}

Posted by 라딘.

댓글을 달아 주세요

count=`ps -ef | grep -v grep | grep myprocess_v1 | wc -l`

if [[ $count -eq 0 ]]
then
        echo "start My Process..... "
        cd $HOME
        $JAVA_HOME/bin/java -Dmyprocess_v1 myprocess
fi

동일한 java process가 myprocess란 이름으로 동작할 때 자기 자신의 process를 구분하기 위해
java -D option으로 process 이름을 구분해준 다음 실행중 여부 확인
Posted by 라딘.

댓글을 달아 주세요