<main.jsp> (꼭 jsp로 작업하지 않아도 된다.)


<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

<script type="text/javascript">


var xhr = null;

function getXMLHttpRequest() {

if (window.ActiveXObject) {

try {

return new ActiveXObject("Msxml2.XMLHTTP");

} catch (e1) {

try {

return new ActiveXObject("Microsoft.XMLHTTP");

} catch (e2) {

return null;

}

}

} else if (window.XMLHttpRequest) {

return new XMLHttpRequest();

} else {

return null;

}

}


function requestHello(URL) {

param = f.name.value;

URL = URL + "?name=" + encodeURIComponent(param);

xhr = getXMLHttpRequest();

xhr.onreadystatechange = responseHello;

xhr.open("GET", URL, true);

xhr.send(null);

}

function responseHello(){

if(xhr.readyState == 4){

var str = xhr.responseText;

document.getElementById("message").innerHTML = str;

}else{

alert(!"Fail : "+httpRequest.status);

}

}

</script>

</head>

<body>

<form name="f">

<input type="text" name="name">

<input type="button" value="입력 " onclick="requestHello('hello.jsp')">

</form>

<div id="message"></div>


</body>

</html>



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


<hello.jsp>


<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

</head>

<body>

<%

request.setCharacterEncoding("UTF-8");

String name = request.getParameter("name");

%>

안녕하세요, <%=name %> 회원님!

</body>

</html>




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




저렇게만 한다면 분명히 한글이 깨질 것이다.


 이 부분을 -> main.jsp : escape(encodeURIComponent(param))

hello.jsp :  java.net.URLDecoder.decode(request.getParameter("name"),"utf-8")


이렇게 다시 바꾸고 실행해보자.

그럼 한글이 제대로 나온다.


그래도 한글이 깨져서 나온다면 잘 저장하고 tomcat 을 restart 하면 된다.


'Client Standard > Ajax' 카테고리의 다른 글

[Jsonp] POST method 데이터전송  (0) 2017.03.30
[Ajax] Http/Https 크로스도메인 문제  (0) 2017.03.27
Js, Ajax Example  (0) 2013.02.23

URL Encoding 특수문자코드

Use this URL Encoding table for special characters:


Character Code Character Code

%26%23169; t %74

® %26%23174; u %75

%E2%84%A2 v %76

backspace %08 w %77

tab %09 x %78

linefeed %0A y %79

creturn %0D z %7A

space %20 { %7B

! %21 | %7C

" %22 } %7D

# %23 ~ %7E

$ %24 %A2

% %25 %A3

& %26 %A5

' %27 | %A6

( %28 § %A7

) %29 %AB

* %2A %AC

+ %2B ? %AD

, %2C º %B0

- %2D ± %B1

. %2E ª %B2

/ %2F , %B4

0 %30 μ %B5

1 %31 %BB

2 %32 ¼ %BC

3 %33 ½ %BD

4 %34 ¿ %BF

5 %35 A` %C0

6 %36 %C1

7 %37 A^ %C2

8 %38 A~ %C3

9 %39 %C4

: %3A %C5

; %3B Æ %C6

< %3C %C7

= %3D E` %C8

> %3E %C9

? %3F E^ %CA

@ %40 %CB

A %41 I` %CC

B %42 %CD

C %43 I^ %CE

D %44 %CF

E %45 Ð %D0

F %46 N~ %D1

G %47 O` %D2

H %48 %D3

I %49 O^ %D4

J %4A O~ %D5

K %4B %D6

L %4C Ø %D8

M %4D U` %D9

N %4E %DA

O %4F U^ %DB

P %50 %DC

Q %51 %DD

R %52 Þ %DE

S %53 ß %DF

T %54 a` %E0

U %55 %E1

V %56 a^ %E2

W %57 a~ %E3

X %58 %E4

Y %59 %E5

Z %5A æ %E6

[ %5B %E7

\ %5C e` %E8

] %5D %E9

^ %5E e^ %EA

_ %5F %EB

` %60 i` %EC

a %61 %ED

b %62 i^ %EE

c %63 %EF

d %64 ð %F0

e %65 n~ %F1

f %66 o` %F2

g %67 %F3

h %68 o^ %F4

i %69 o~ %F5

j %6A %F6

k %6B ÷ %F7

l %6C ø %F8

m %6D u` %F9

n %6E %FA

o %6F u^ %FB

p %70 %FC

q %71 %FD

r %72 þ %FE

s %73 %FF




1. []으로 싸주면 문자자체로 인식하는 것들. 


*  ⇒ [*] 

+  ⇒ [+] 

$  ⇒ [$] 

|  ⇒ [|] 



2. \\를 붙여줘야 하는 것들. 


( ⇒ \\( 

) ⇒ \\) 

{ ⇒ \\{ 

} ⇒ \\} 

^ ⇒ \\^ 

[ ⇒ \\[ 

] ⇒ \\] 



3. 자바의 특수문자는 \을 쓴다. 


 " ⇒ \" 



4. 나머지 부호들은 괜찮은 듯 하다. 

확인된 것. 


! # % & @ ` : ; - . < > , ~ ' 




ex ) 위에 놈들 다 지워 보자. 


    String c = "!\"#$%&(){}@`*:+;-.<>,^~|'[]"; 

    c = c.replaceAll("!\"#[$]%&\\(\\)\\{\\}@`[*]:[+];-.<>,\\^~|'\\[\\]", ""); 





 public static String getSTRFilter(String str){ 

  int str_length = str.length(); 

  String strlistchar   = ""; 

  String str_imsi   = "";  

  String []filter_word = {"","\\.","\\?","\\/">\\~","\\!","\\@","\\#","\\$","\\%","\\^","\\&","\\*","\\(","\\)","\\_","\\+","\\=","\\|","\\\\","\\}","\\]","\\{","\\[","\\\"","\\'","\\:","\\;","\\<","\\,","\\>","\\.","\\?","\\/"}; 


  for(int i=0;i<filter_word.length;i++){ 

   //while(str.indexOf(filter_word[i]) >= 0){ 

      str_imsi = str.replaceAll(filter_word[i],""); 

      str = str_imsi; 

   //} 

  } 


  return str; 


 } 




import java.util.StringTokenizer; 


public class WebUtil 

           // 문자열 변환  String a= "abc" => replace(a, "c") => a : ab 

           public String strReplace(String s1, String s2){ 

                      String res = ""; 

                      StringTokenizer str = new StringTokenizer(s1, s2); 



                       while(str.hasMoreTokens()){ 

                                     res += str.nextToken();   

                               System.out.println(res); 

                       } 

               return res; 

           } 

}



출처 : http://lazli.tistory.com/47

-- Java DateFormat


ex1)

SimpleDateFormat df = new SimpleDateFormat("yyyy년 MM월 dd일 hh시 mm분 ss초");

//SimpleDateFormat df= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

//SimpleDateFormat df= new SimpleDateFormat("yyyy-MM-dd");


Date date = new Date();

String today = df.format(date);

System.out.println(today);


Calendar c = Calendar.getInstance();

String today2 = df.format(c.getTime());

System.out.println(today2);




ex2)

Date now = new Date();

DateFormat format1 = DateFormat.getDateInstance(DateFormat.FULL);
System.out.println(format1.format(now));
DateFormat format2 = DateFormat.getDateInstance(DateFormat.LONG);
System.out.println(format2.format(now));
DateFormat format3 = DateFormat.getDateInstance(DateFormat.MEDIUM);
System.out.println(format3.format(now));
DateFormat format4 = DateFormat.getDateInstance(DateFormat.SHORT);
System.out.println(format4.format(now));



2009년 5월 29일 금요일
2009년 5월 29일 (금)
2009. 5. 29
09. 5. 29






-- 날째 객체 현재 날짜 비교


Date memDelStartDate; // 삭제 시작일

Date currentDate; // 현재날짜 Date

String oTime = ""; // 현재날짜

String compareVal = "N";



SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat ( "yyyy-MM-dd", Locale.KOREA );

Date currentTime = new Date();

oTime = mSimpleDateFormat.format ( currentTime ); //현재시간 (String)


memDelStartDate = mSimpleDateFormat.parse( "2015-07-31" );

currentDate =  mSimpleDateFormat.parse( oTime );

int compare = currentDate.compareTo( memDelStartDate ); // 날짜비교


if ( compare > 0 ){ // 현재날짜가 삭제 시작일 후 인 경우

//System.out.println("currentDate  >  memDelStartDate");

compareVal = "N";

} else if ( compare < 0) { // 현재날짜가 삭제 시작일 전 인 경우

compareVal = "Y";

//System.out.println("currentDate  <  memDelStartDate");

} else { // 현재날짜가 삭제 시작일 인 경우

compareVal = "Y";

//System.out.println("currentDate  =  memDelStartDate");

}

'Server Enterprise > Java' 카테고리의 다른 글

URL Encoding 특수문자 코드  (0) 2015.07.22
[Encode] java replaceall 특수문자  (0) 2015.07.22
[String Replace] email 개인정보 asterisk 치환  (0) 2015.06.13
[decompile] java decompiler  (0) 2014.12.30
[Encode] 한글 인코딩  (0) 2014.08.15

- 함수 권한 주기

grant execute
on 함수명
to  사용자이름(스키마이름)



- 함수 삭제

DROP FUNCTION PRMIT.GET_FUNCTION

href 값 안

/secondMain.do#suikbunbe


위와같은 포커싱이라면 가지않는다


/secondMain.do%23suikbunbe 


하기와 같이 특수문자들은 # -> %23 인코딩 해주어야 메일함에서 링크 이동후 포커싱이 된다

// 테스트 이메일 array

String email[] = { "denodo1@gmail.com", 

"forever3031@gmail.com", 

"titleaaaa3@gmail.com", 

"ssangssyo@gmail.com" };


// split("@") 하기위한 변수

String[] switchEmail = null;


// 결과값 담는 변수

String resultEmail="";



for(int i=0; i<email.length; i++) {

switchEmail = email[i].split("@");

// 정보보호 결과값 담는 변수

String contentEmail="";


for(int j=0; j<switchEmail[0].length(); j++) {

if(j == 2 || j==3 || j==4 ) {

contentEmail += "*";

}else {

contentEmail += switchEmail[0].charAt(j);

}

}


resultEmail = contentEmail + "@" + switchEmail[1];

System.out.println("전환후 이메일                ::           "+i+"    " + resultEmail);

}

'Server Enterprise > Java' 카테고리의 다른 글

[Encode] java replaceall 특수문자  (0) 2015.07.22
[Date] 날짜 객체 현재 날짜 비교 / DateFormat  (0) 2015.07.08
[decompile] java decompiler  (0) 2014.12.30
[Encode] 한글 인코딩  (0) 2014.08.15
[Image Object] width, height  (0) 2014.03.11


방법1:

INSERT ALL

INTO table (column1, column2)

VALUES (value1, value2)

INTO table (column1, column2)

VALUES (value1, value2)

...etc...

SELECT * FROM DUAL;


방법2:

INSERT INTO table (column1, column2)

SELECT value1, value2 FROM DUAL UNION ALL

SELECT value1, value2 FROM DUAL UNION ALL

...etc...

SELECT value1, value2 FROM DUAL;



DBMS Tool 1:

INSERT INTO table (column1, column2) VALUES (value1, value2);

INSERT INTO table (column1, column2) VALUES (value1, value2);

INSERT INTO table (column1, column2) VALUES (value1, value2);

INSERT INTO table (column1, column2) VALUES (value1, value2);

INSERT INTO table (column1, column2) VALUES (value1, value2);

...etc...

INSERT INTO table (column1, column2) VALUES (value1, value2);

<!-- 로그인 세션 60분 x 3 = 3시간 설정 -->

<session-config>

<session-timeout>180</session-timeout>

</session-config>


<!-- 404, 500, 501 에러에대한 jsp error 페이지 설정 -->

<error-page>

<error-code>404</error-code>

<location>/WEB-INF/jsp/common/error/error404.jsp</location>

</error-page>

<error-page>

<error-code>500</error-code>

<location>/WEB-INF/jsp/common/error/error404.jsp</location>

</error-page>

<error-page>

<error-code>501</error-code>

<location>/WEB-INF/jsp/common/error/error404.jsp</location>

</error-page>


<!-- http 요청 메소드 제한 설정 : DELETE, PUT, OPTIONS, TRACE, PATCH 대한 메소드 막음 -->

<security-constraint>

<web-resource-collection>

<web-resource-name>NoAccess</web-resource-name>

<url-pattern>*.do</url-pattern>

<http-method>DELETE</http-method>

<http-method>PUT</http-method>

<http-method>OPTIONS</http-method>

<http-method>TRACE</http-method>

<http-method>PATCH </http-method>

</web-resource-collection>

<auth-constraint />

</security-constraint>


<!-- index 페이지 설정 -->

<welcome-file-list>

<welcome-file>welcome.jsp</welcome-file>

<welcome-file>index.jsp</welcome-file>

</welcome-file-list>

// 모바일 여부 확인

String header = request.getHeader("User-Agent").toLowerCase().replaceAll(" ", "");

if (header.indexOf("mobile") != -1) {

member.setChannel("20");

} else {

member.setChannel("10");

}


tip)

요청 방식 = <%=request.getMethod()%><br>
요청 URI = <%=request.getRequestURI()%><br>
요청 프로토콜= <%=request.getProtocol()%><br>

<p>

서블릿 경로 = <%=request.getServletPath()%><br>
요청 쿼리문자열= <%=request.getQueryString()%><br>
서버 이름 = <%=request.getServerName()%><br>
서버 포트 = <%=request.getServerPort()%><br>

<p>

클라이언트 접속주소 = <%=request.getRemoteAddr()%><br>
클라이언트 접속호스트 = <%=request.getRemoteHost()%><br>
인증 스키마= <%=request.getAuthType()%><br>
접속 국가 = <%=request.getLocale()%><br>

<p>
사용하는 브라우저=<%=request.getHeader("user-agent")%>

+ Recent posts