JSP2013. 12. 5. 16:33

브라우저 헤더 설정  : Change HTTP Request Header 1.1.1


브라우저 JSON 으로 보기 : JSONView  (크롬에서 종종 두번 호출하는 오류 있음 )

Posted by 선한열심
JSP2013. 6. 27. 23:14

리소스 properties 파일 이용하기

3가지 방법 

1. fmt bundle 이용
<fmt:setLocale value="ko_KR"/>
<fmt:setBundle basename="resource" var="lang" />
<fmt:message key="fruits.apple" bundle="${lang}" />
</body>
</html>

파일 위치는 /WEB-INF/src바로 밑에

* resource.properties

fruits.apple=apple
fruits.strawberry=strawberry
fruits.banana=banana

 

 

2. 프로젝트 \WEB-INF\web.xml  안에 추가할수도 있네요

  <context-param>
  <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
  <param-value>JeongMessageBundle</param-value>
</context-param>

파일위치 : classes\JeongMessageBundle.properties

 

3. JSP 에서 사용

Copy properties file in WEB-INF/classes folder

Suppose we have file commonVariable.properties in WEB-INF/classes folder

# forum path and properties
forum.path=forum
forum.url=forum
forum.database=jspforum
forum.use=yes

JSP which is getting values from ResourceBundle properties file

resource.jsp

<%@ page language="java" import="java.util.*" %>
<%
ResourceBundle resource = ResourceBundle.getBundle("commonVariable");
/// commonVariable.properties file will be in WEB-INF/classess  folder

String sPath=resource.getString("forum.path");
String sName=resource.getString("forum.database");

System.out.println(sPath);
System.out.println(sName);

%>

 

Posted by 선한열심
JSP2013. 6. 19. 14:34

1. ~.tld 파일 설정

    기본적으로 web.xml 에 taglib 를 등록하지만 WEB-INF/ 밑에 ~.tld 파일이 있을 경우 따로 설정하지 않아도 된다.

   JSP에서는 tld파일의 taglib 태그의 uri 태그 값으로 불러와서 사용하면 됨

  예)  tld파일 : WEB-INF/ 밑에 있어야함

        tld파일안에  : <uri>net.ucware.tags</uri>

        jsp : <%@ taglib prefix="ast" uri="net.ucware.tags" %>

 

2. 커스텀 태그 정리 중....

HearderTag.java

public class DefaultConfigTag extends TagSupport

    private String var;
    public void setVar(String var) {
        this.var = var;
    } 
 
    public int doStartTag() throws JspException {
        String value = "aaa";
        pageContext.setAttribute(var, value);
       
        아니면
       
        JspWriter out = pageContext.getOut();
        ou.print("aaa");
        return SKIP_BODY;
    }
}

<exam:mutiply op1="2" start="1" end="9" >

</exam>

<exam:mutiply op1="2" start="1" end="9" >

 ${pageContext.op1} * ${pageContext.op2} =  ${pageContext.op1 * pageContext.op2} <br>   <=== 몸체라고함

</exam:multiply>


Return 값 종류

doStartTag()  

    SKIP_BODY                  : 몸체 내용을 처리하지 않는다

    EVAL_BODY_INCLUDE : 몸체 내용을 처리한 결과를 출력한다.

doAfterBody()  

    EVAL_BODY_AGAIN  이면 몸체 다시 실행 do{ }while(조건) 처럼

    SKIP_BODY                  : 몸체 내용을 처리하지 않는다

 



Posted by 선한열심
JSP2013. 6. 19. 10:39

Working with server:

<%=application.getServerInfo() %>

Servlet Specification:

<%=application.getMajorVersion()%>.<%= application.getMinorVersion() %>

JSP version:

<%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion() %>

[출처] JSP버전 확인|작성자 matzip84


Posted by 선한열심
JSP2013. 6. 5. 13:37

<fmt: bundle>태그와 <fmt:message>태그

Posted by 선한열심
JSP2013. 4. 29. 15:11

<jsp:include page=...>과 <@include file=...>의 차이

 

예) main.jsp 안에 <jsp:include page='a.jsp'> 는 main.jsp 안에 포함되어 컴파일 된다 (정적)

  main.jsp 안에 <jsp:include page='b.jsp'>  는 따로 따로 컴파일되어 main.jsp 파일의 변수를 b.jsp 파일에서 사용할 수 없다

 

 

Posted by 선한열심