Posted
Filed under JSP, JAVA
[참고]https://github.com/naver/lucy-xss-servlet-filter
pom.xml 추가
<dependency>
<groupId>com.navercorp.lucy</groupId>
<artifactId>lucy-xss-servlet</artifactId>
<version>2.0.0</version>
</dependency>

 

[web.xml]
filter 순서 UTF-8 인코딩 필터가 있다면 그 다음으로
multipartFilter  추가 후 XSS filter 추가 한다.
이유) 게시판 파일 업로드  enctype="multipart/form-data"
일떄 multipartFilter 필터 타지 않을 수 있음 그래서 필터 순서를 맞춰줘야 함

<!-- multipartFilter -->
<filter>
<filter-name>multipartFilter</filter-name>
<filter-class>
org.springframework.web.multipart.support.MultipartFilter
</filter-class>
</filter>

<filter-mapping>
<filter-name>multipartFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<!-- xss filter -->
<filter>
<filter-name>xssEscapeServletFilter</filter-name>
<filter-class>com.navercorp.lucy.security.xss.servletfilter.XssEscapeServletFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>xssEscapeServletFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

[root-context.xml]에  multipartResolver   bean설정시 아이디를
multipartResolver --> filterMultipartResolver 변경 해줌
그래야 xss 필터가 정상적으로 동작

<!-- multipartResolver -->
<!--<beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />-->
<beans:bean id="filterMultipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />

2019/01/30 18:55 2019/01/30 18:55
Posted
Filed under JSP, JAVA
xml설정
xmlns:task="http://www.springframework.org/schema/task"

xsi:schemaLocation 부분에 
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-4.0.xsd

추가
<task:annotation-driven /> 추가



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

1초마다 한번식 실행

@Service
public class VisitorConfig {
@Scheduled(fixedDelay = 1000)
public void visitor(){
System.out.println("test:");
}
}
2019/01/28 11:17 2019/01/28 11:17
Posted
Filed under JSP, JAVA
[원문]
http://krams915.blogspot.com/2010/12/spring-security-mvc-querying.html @Resource(name="sessionRegistry") private SessionRegistryImpl sessionRegistry; for (Object username: sessionRegistry.getAllPrincipals()) { logger.debug(username); }
2019/01/14 12:08 2019/01/14 12:08
Posted
Filed under JSP, JAVA

tomcat8
/webapp/manager/META-INF/context.xml

<!--Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /-->
주석 처리가 되어 있다면
주석을 해제하여 외부에서 접근 하는 것을 막을 수 있다.


2018/04/09 14:28 2018/04/09 14:28
Posted
Filed under JSP, JAVA
select FLOOR((DayOfMonth(20180221)-1)/7)+1
or

select FLOOR((DayOfMonth(now())-1)/7)+1
2018/02/23 15:17 2018/02/23 15:17
Posted
Filed under JSP, JAVA

CREATE OR REPLACE FUNCTION is_number(v_str_number IN varchar2)

RETURN NUMBER

IS  /* 데이터가 number 형인지 검사하는 함수임. 1 이 나오면 NUMBER 형임 */

     V_NUM NUMBER;

BEGIN

  V_NUM := TO_NUMBER(v_str_number);

  RETURN 1;

EXCEPTION

  WHEN OTHERS THEN RETURN 0    ;

END;

 


CREATE OR REPLACE FUNCTION is_date(v_str_date IN varchar2, V_FORMAT IN VARCHAR2 DEFAULT 'YYYYMMDD')

RETURN NUMBER

IS   /* 데이터가 DATE 형인지 검사하는 함수임. 1 이 나오면 DATE 형임 */

     V_DATE DATE;

BEGIN

  V_DATE := TO_DATE(v_str_date, V_FORMAT);

  RETURN 1;   

EXCEPTION

  WHEN OTHERS THEN RETURN 0    ;

END; 

 




출처: http://scidb.tistory.com/entry/오라클에서-isnumber-isdate-함수-사용하기 [Science of Database]

2018/02/21 10:58 2018/02/21 10:58
Posted
Filed under JSP, JAVA
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/maps/*.xml</include>
</includes>
</resource>
</resources>

pom.xml 파일에 빌드 요소 하단에 다음과 같이 추가 한다.
2018/02/20 10:11 2018/02/20 10:11
Posted
Filed under JSP, JAVA
tomcat 의 web.xml 또는
프로젝트의 web.xml에 다음과 같이 추가 한다


<filter>
 <filter-name>httpHeaderSecurity</filter-name>
 <filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
 <init-param>
 <param-name>antiClickJackingOption</param-name>
 <param-value>SAMEORIGIN</param-value>
 </init-param>
</filter>
<filter-mapping>
 <filter-name>httpHeaderSecurity</filter-name>
 <url-pattern>/*</url-pattern>
</filter-mapping>
2018/01/26 17:40 2018/01/26 17:40
Posted
Filed under JSP, JAVA
java8 부터 다음과 같이 메모리 설정을 한다.
-XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=2048m

2017/12/19 14:50 2017/12/19 14:50
Posted
Filed under JSP, JAVA
import javax.script.ScriptEngineManager;
import javax.script.ScriptEngine;

publicclassTest{
 
publicstaticvoid main(String[] args)throwsException{
   
ScriptEngineManager mgr =newScriptEngineManager();
   
ScriptEngine engine = mgr.getEngineByName("JavaScript");
   
String foo ="40+2";
   
System.out.println(engine.eval(foo));
   
}
}

samed  javascript  eval function

출처: http://unikys.tistory.com/226

2017/11/23 11:32 2017/11/23 11:32