Programming/jsp2014. 3. 27. 19:43
jsp 파일에서 page를 통해 buffer를 설정이 가능하다.
기본값은 8K 에 autoFlush(=true) 하도록 되어 있다.
<%@ page contentType="text/html; charset=euc-kr"%>
<%@ page buffer="16kb" autoFlush="false"%> 

jsp 파일에서 설정된 내용은 java/class로 변환되는데 
public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html; charset=EUC-KR");
      pageContext = _jspxFactory.getPageContext(this, request, response,
       null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out; 

javax.servlet.jsp.JspFactory.getPageContext() 메소드를 통해 설정하게 된다.
java.lang.Object
  extended by javax.servlet.jsp.JspFactory
 
public abstract PageContext getPageContext(Servlet servlet,
                                           ServletRequest request,
                                           ServletResponse response,
                                           String errorPageURL,
                                           boolean needsSession,
                                           int buffer,
                                           boolean autoflush)
 
[링크 : http://docs.oracle.com/javaee/5/api/javax/servlet/jsp/JspFactory.html#getPageContext(...)

Posted by 구차니
Programming/jsp2014. 3. 27. 19:32
jsp의 scope가 있는데
page는 하나의 페이지에 대해서 유효
request는 HTTP request 에 대해서 유효
session은 HTTP session에 대해서 유효
applicatoin은 WAS에 대해서 유효한 값 범위를 지닌다.

조금 다르게 설명을 하면
page는 단일 jsp 파일 하나에 대한
request는 jsp 파일 하나에서 링크로 이어지는 파일까지
session은 웹 브라우저에서 서버로 접속한 세션이 유효한 동안(주로 로그인 인증에 사용)
application은 웹 서버에서 서비스 하는 하나의 전체 홈페이지에 대해서 유효하다.


There are four possible scopes:
  • scope="page" (default scope): The object is accessible only from within the JSP page where it was created. A page-scope object is stored in the implicitpageContext object. The page scope ends when the page stops executing.

    Note that when the user refreshes the page while executing a JSP page, new instances will be created of all page-scope objects.

  • scope="request": The object is accessible from any JSP page servicing the same HTTP request that is serviced by the JSP page that created the object. A request-scope object is stored in the implicit request object. The request scope ends at the conclusion of the HTTP request.

  • scope="session": The object is accessible from any JSP page that is sharing the same HTTP session as the JSP page that created the object. A session-scope object is stored in the implicit session object. The session scope ends when the HTTP session times out or is invalidated.

  • scope="application": The object is accessible from any JSP page that is used in the same Web application as the JSP page that created the object, within any single Java virtual machine. The concept is similar to that of a Java static variable. An application-scope object is stored in the implicitapplication servlet context object. The application scope ends when the application itself terminates, or when the JSP container or servlet container shuts down.

[링크 : http://docs.oracle.com/cd/B14099_19/web.1012/b14014/genlovw.htm

Scope is nothing but lifetime object 

1.page - only in the particular jsp
2.request- only in the jsp to which you forward your request object
3.session- it is available until the session is invalidate(you can access it from any jsp)
4.application-it is available until the web application or server shutdown(you can access it from any jsp).available through whole application
 
[링크 : http://www.coderanch.com/.../certification/Page-Scope-request-Scope-session

[링크 : http://docs.oracle.com/javaee/1.4/api/javax/servlet/jsp/PageContext.html]
[링크 : http://www.java-samples.com/showtutorial.php?tutorialid=1009]

'Programming > jsp' 카테고리의 다른 글

jsp error 페이지 사이즈 제한(IE)  (0) 2014.03.27
jsp buffer  (0) 2014.03.27
JSP에서 euc-kr로 할 경우 저장이 안되는 한글이 있다?  (0) 2014.03.26
JSP 기본 문법  (0) 2014.03.26
웹 서버 및 서비스 개요(java/jsp)  (0) 2014.03.26
Posted by 구차니
Programming/jsp2014. 3. 26. 21:34


이 녀석.. 아마도 완성형 코드인 euc-kr 에서 인식하지 못하기에
유니코드인 utf-8로 해야지 저장이 가능한 듯

이클립스에서 JSP 로 작업후 저장시 아래와 같이 UTF-8로 변환하길 권장한다.


[링크 : http://tapito.tistory.com/173] 완성형 문자표
[링크 : http://ko.wikipedia.org/wiki/EUC-KR ]

'Programming > jsp' 카테고리의 다른 글

jsp buffer  (0) 2014.03.27
jsp - page / request / session / applicaton  (0) 2014.03.27
JSP 기본 문법  (0) 2014.03.26
웹 서버 및 서비스 개요(java/jsp)  (0) 2014.03.26
Apache tomcat  (0) 2014.03.25
Posted by 구차니
Programming/jsp2014. 3. 26. 20:12
문법이라고 하기에도 애매하지만..
아무튼 치환자의 종료는 4가지가 있다.

 디렉티브 (Directive)  <%@ %> (import)
 스크립트릿 (Scriptlet)  <% %> (코드 영역 / 메소드 선언 불가)
 표현식 (Expression)  <%= %>(웹페이지로 출력)
 선언부 (Declaration)  <%! %> (메소드 선언 영역)
 
 
JSP는 jsp 파일이 내부적으로 WAS를 통해 *.java로 변경되며 *.class로 컴파일 된다. 
eclipse와 연동시 아래의 경로에 해당 class 파일과 java 파일이 생성된다.

workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost 


<%= %>의 경우는
out.print()와 동일하게 작동한다.
System.out.print()는 WAS의 콘솔로 출력하게 되니 주의!!!
[링크 : http://www.jsptut.com/Scriptlets.jsp]

out은 JspWriter의 out이다 ㄷㄷㄷ
public void _jspService(HttpServletRequest request, HttpServletResponse response)
    throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
 
[링크 : http://stackoverflow.com/questions/10396347] 
[링크 : http://docs.oracle.com/javaee/7/api/javax/servlet/jsp/JspWriter.html]

'Programming > jsp' 카테고리의 다른 글

jsp buffer  (0) 2014.03.27
jsp - page / request / session / applicaton  (0) 2014.03.27
JSP에서 euc-kr로 할 경우 저장이 안되는 한글이 있다?  (0) 2014.03.26
웹 서버 및 서비스 개요(java/jsp)  (0) 2014.03.26
Apache tomcat  (0) 2014.03.25
Posted by 구차니
Programming/jsp2014. 3. 26. 20:07
WAS - Web Application Server (Apache Tomcat)

tomcat 수동으로 구동시 반드시 설정해야 할 환경변수
JAVA_HOME
JRE_HOME
CATALINA_HOME
[링크 : http://tomcat.apache.org/]

컴파일 된 파일들 삭제하는 방법

 

JSTL/EL - javaEE의 기술 중 하나
JSP Standard Tag Library/Expression Language

'Programming > jsp' 카테고리의 다른 글

jsp buffer  (0) 2014.03.27
jsp - page / request / session / applicaton  (0) 2014.03.27
JSP에서 euc-kr로 할 경우 저장이 안되는 한글이 있다?  (0) 2014.03.26
JSP 기본 문법  (0) 2014.03.26
Apache tomcat  (0) 2014.03.25
Posted by 구차니
Programming/Java2014. 3. 25. 21:33
JNI(Java Native Interface)
[링크 : http://docs.oracle.com/javase/6/docs/technotes/guides/jni/]
[링크 : http://en.wikipedia.org/wiki/Java_Native_Interface]

JNI를 통해 자바를 다른 언어에서
혹은 다른 언어에서 자바를 호출할 수 있다.

[링크 : http://deguls.tistory.com/entry/JNI-HelloWorld자바에서-C함수-호출] java에서 c 호출
[링크 : http://scotthan.tistory.com/129]  c에서 java 호출

'Programming > Java' 카테고리의 다른 글

JDNI - Java Directory & Naming Interface  (0) 2014.05.09
jdk 1.5 - annotation / @  (0) 2014.05.08
java TCP/UCP socket  (0) 2014.03.25
java object serializable / ObjectInputStream + ObjectOutputStream  (0) 2014.03.24
Java Input/OutputStream 관련  (0) 2014.03.21
Posted by 구차니
Programming/jsp2014. 3. 25. 17:12
jakarta tomcat 이 프로젝트 종료되면서
apache tomcat 으로 이전 된 듯?

21 December 2011 - Jakarta Retired

With no subprojects remaining, the Jakarta project has been retired to the Attic.

[링크 : https://jakarta.apache.org/
    [링크 : https://jakarta.apache.org/site/news/news-2011-q4.html#20111221.1

[링크 : http://en.wikipedia.org/wiki/Jakarta_Project]
[링크 : http://en.wikipedia.org/wiki/Apache_Tomcat]

'Programming > jsp' 카테고리의 다른 글

jsp buffer  (0) 2014.03.27
jsp - page / request / session / applicaton  (0) 2014.03.27
JSP에서 euc-kr로 할 경우 저장이 안되는 한글이 있다?  (0) 2014.03.26
JSP 기본 문법  (0) 2014.03.26
웹 서버 및 서비스 개요(java/jsp)  (0) 2014.03.26
Posted by 구차니
Programming/Java2014. 3. 25. 00:33
TCP는 소켓 자체가 서버용/클라이언트 용으로 나뉘지만
UDP는 컨스트럭터의 인자에 따라서 서버용과 클라이언트용으로 구분된다.

ServerSocket은
accpet() 시에 다른 포트를 return 하게 되는데
이는 서비스 포트를 접속용으로 사용하게 되면 다른 클라이언트들이 접속할 수 없게 되므로 서비스 포트를 비워두기 위함이다.

Server ready...
SRV SOCK localport 3333
ACC SOCK localport 3333, port 2914
Server ready...
SRV SOCK localport 3333
ACC SOCK localport 3333, port 2915 

System.out.println("SRV SOCK localport " + serverSocket.getLocalPort());
System.out.println("ACC SOCK localport " + socket.getLocalPort() + ", port " + socket.getPort()); 




TCP
Server Socket
Socket accept() 
Listens for a connection to be made to this socket and accepts it.
 

[링크 : http://download.java.net/jdk8/docs/api/java/net/ServerSocket.html  

ServerSocket serverS = new ServerSocket(port);
Socket tcpSocket = serverS.accept();
InputStream is = tcpSocket.getInputStream();
OutputStream os = tcpSocket.getOutputStream();
BufferedReader bufferR = new BufferedReader(new InputStreamReader(is));
BufferedWriter bufferW = new BufferedWriter(new OutputStreamWriter(os)); 

bufferR.read();

bufferW.write();
bufferW.flush(); 

Client Socket
Socket tcpSocket = new Socket(ip, port);
InputStream is = tcpSocket.getInputStream();
OutputStream os = tcpSocket.getOutputStream();
BufferedReader bufferR = new BufferedReader(new InputStreamReader(is));
BufferedWriter bufferW = new BufferedWriter(new OutputStreamWriter(os)); 

bufferR.read();

bufferW.write();
bufferW.flush(); 

[링크 : http://download.java.net/jdk8/docs/api/java/net/Socket.html
 


UDP
DatagramPacket(byte[] buf, int length) Constructs for receiving
DatagramPacket(byte[] buf, int length, InetAddress address, int port) Constructs for sending
[링크 : http://download.java.net/jdk8/docs/api/java/net/DatagramPacket.html]

DatagramSocket(int port) Constructs a datagram socket and binds it to the specified port on the local host machine.
DatagramSocket(int port, InetAddress laddr) Creates a datagram socket, bound to the specified local address.

void receive(DatagramPacket p) Receives a datagram packet from this socket.
void send(DatagramPacket p) Sends a datagram packet from this socket.
[링크 : http://download.java.net/jdk8/docs/api/java/net/DatagramSocket.html] 

DatagramSocket ds = new DatagramSocket(port);
DatagramPacket dp = new DatagramPacket(buffer, buffer.length);

ds.receive(dp);
ds.send(dp);



'Programming > Java' 카테고리의 다른 글

jdk 1.5 - annotation / @  (0) 2014.05.08
java <-> c 상호호출  (0) 2014.03.25
java object serializable / ObjectInputStream + ObjectOutputStream  (0) 2014.03.24
Java Input/OutputStream 관련  (0) 2014.03.21
java 8을 윈XP에 설치하자?  (2) 2014.03.20
Posted by 구차니
Programming/Java2014. 3. 24. 16:59
transient 키워드는 객체 저장시 제외할 항목을 지정한다.(예를 들어 런타임 변수등을 저장할 이유는 없으니)

ObjectOutputStram.writeObject()과
ObjectInputStram.readObject()을 오버라이딩 함으로서

파일로 저장(직렬화 해야 파일로 저장이 가능하니)시 저장할 내용을 커스터마이징 할 수 있다.

[링크 : http://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html]
[링크 : http://docs.oracle.com/javase/7/docs/api/java/io/ObjectOutputStream.html#writeObject(java.lang.Object)]
[링크 : http://docs.oracle.com/javase/7/docs/api/java/io/ObjectInputStream.html#readObject()]

[링크 : http://docs.oracle.com/javase/tutorial/reflect/member/fieldModifiers.html]
[링크 : http://www.oracle.com/technetwork/articles/java/javaserial-1536170.html ]
[링크 : http://stackoverflow.com/questions/910374/why-does-java-have-transient-variables

'Programming > Java' 카테고리의 다른 글

java <-> c 상호호출  (0) 2014.03.25
java TCP/UCP socket  (0) 2014.03.25
Java Input/OutputStream 관련  (0) 2014.03.21
java 8을 윈XP에 설치하자?  (2) 2014.03.20
java 8 released!!  (0) 2014.03.20
Posted by 구차니
Programming/Java2014. 3. 21. 23:56
Buffered- 의 경우에는
버퍼되지 않는 스트림을 감싸서 사용한다.

 BufferedInputStream(new FileInputStream()) 

[링크 : http://docs.oracle.com/javase/7/docs/api/java/io/FileInputStream.html]
[링크 : http://docs.oracle.com/javase/7/docs/api/java/io/FileOutputStream.html]
[링크 : http://docs.oracle.com/javase/8/docs/api/java/io/BufferedInputStream.html]
[링크 : http://docs.oracle.com/javase/8/docs/api/java/io/BufferedOutputStream.html]


또한, Reader/Writer는 2byte unicode를 기본 지원하나
다른 스트림은 기본적으로 1byte ascii 이기 때문에 한글 입출력에 문제가 발생할 수 있다.

[링크 : http://docs.oracle.com/javase/tutorial/essential/io/buffers.html]
  [링크 : http://docs.oracle.com/javase/8/docs/api/java/io/BufferedReader.html]
  [링크 : http://docs.oracle.com/javase/8/docs/api/java/io/BufferedWriter.html

  [링크 : http://docs.oracle.com/javase/8/docs/api/java/io/InputStreamReader.html]
  [링크 : http://docs.oracle.com/javase/8/docs/api/java/io/OutputStreamWriter.html]

---
2014.03.24 추가

바이트 스트림(1byte) 는 InputStramOutputStream이 최상위 객체이며
[링크 : http://docs.oracle.com/javase/tutorial/essential/io/bytestreams.html
    [링크 : http://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html]
    [링크 : http://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html]

캐릭터 스트림(2byte / unicode)는 ReaderWrtier가 최상위 객체이다.
[링크 : http://docs.oracle.com/javase/tutorial/essential/io/charstreams.html]
    [링크 : http://docs.oracle.com/javase/8/docs/api/java/io/Reader.html]
    [링크 : http://docs.oracle.com/javase/8/docs/api/java/io/Writer.html

'Programming > Java' 카테고리의 다른 글

java TCP/UCP socket  (0) 2014.03.25
java object serializable / ObjectInputStream + ObjectOutputStream  (0) 2014.03.24
java 8을 윈XP에 설치하자?  (2) 2014.03.20
java 8 released!!  (0) 2014.03.20
java assert  (0) 2014.03.20
Posted by 구차니