반응형

[ 서 론 ]

해당 게시물은 인터넷에 여러 떠돌아 다니는 정보를 종합해서

제가 이해한 수준으로 적습니다.

우리는 HashCode 라는 메소드를 자주 사용합니다. 때론 골때리는 경우가 발생할 수 있는데요..

과연 HashCode값은 유일성을 보장해 주는것인가?  .흠... 절대 아닌듯...

[ 결 론 ]

우리가 보통

HashMap map = new HashMap();
map.put("test","1234");

라고 넣는다 key는 test 이다. 그럼 내부로직은 어떻게 될까? test라는 String 문자열값을 hasCode 화 하여 저장한다.

API에 보면 아래와 같이 공식이 적혀있다.


public int hashCode()
Returns a hashcode for this string. The hashcode for a String object is computed as
 s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
using int arithmetic, where s[i] is the ith character of the string, n is the length of the string, and ^ indicates exponentiation. (The hash value of the empty string is zero.)
Overrides:
hashCode in class Object
Returns:
a hash code value for this object.
 

주저리 주저리 영어로 되어있지만 결론적으로 네모 박스 안에가 공식이다.

저런 공식을 통해 return 값은 int 타입이다.

즉, 4,294,967,295 개 반환 가능하다는 말이다.

이말인즉 언젠가는 겹칠 가능성이 존재한다는것이다. 왜냐 String은 JVM이 뻐티는 한 무한대로

생성가능하기 때문이다.

따라서 내부적으로 HashCode값과 뭔가를 같이 써야지만, 중복없는 hashCode값이 생성될것이다.

이상!!!! 끝!

반응형

'Program > JAVA' 카테고리의 다른 글

POJO(Plain Old Java Object) 란?  (5) 2010.11.05
Abstract Class란?  (0) 2010.09.16
Spring 설정 방법 - UPDATE중  (0) 2010.02.09
[ Factory Pattern ]  (0) 2010.02.07
Properties Class를 이용하여 설정파일 가져오기  (0) 2010.02.06
반응형
Javascript에는 여러가지 인코딩 방식이 있습니다.
 
1) encodeURI() => 정말 최소한의 문자만 인코딩합니다.
2) encodeURIComponent => 별의별 특수문자까지 모두 인코딩합니다.
3) escape() => 1)과 2) 번의 중간입니다.
 
테스트를 해보니 2,3)은 !@#$%^&*() 의 특수문자가 모두 인코딩이 되는군요
 
     paramString += input.name + "=" + encodeURIComponent(input.value) + "&";
 
소스를 참조하시고 2번 방법을 사용하시면 될것 같습니다.

반응형
반응형

web.xml에서 JSP페이지에 보안설정을 하는 방법
web.xml에 *.jsp 패턴의 모든 URL에 대해서 누구도 실행을 할 수 없게 설정해줄 수 있습니다. 아래 처럼 세팅하면 됩니다.

<security-constraint>

  <display-name>JSP Protection</display-name>

  <web-resource-collection>

    <web-resource-name>SecureJSPPages</web-resource-name>

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

  </web-resource-collection>

  <auth-constraint>

    <role-name>nobody</role-name>

  </auth-constraint>

</security-constraint>

 

<security-role>

<description>

Nobody should be in this role so JSP files are protected

from direct access.

</description>

<role-name>nobody</role-name>

</security-role>

 

어떤 의도를 가진 사용자가 JSP 페이지를 URL로 직접 접근하게 되면 서버는 HTTP 응답코드 401번(Unauthorized) 페이지를 보여줍니다.좀더 우아하게 처리하려면 401번 응답 페이지를 예쁘게 만들어서 등록하면 되겠죠.

<!-- 접근 권한없음 : UNAUTHORIZED-->

<error-page>

  <error-code>401</error-code>

  <location>/error/unauthorized.html</location>

</error-page>


 

반응형

'Program > JSP' 카테고리의 다른 글

2차 도메인 Cookie 공유  (0) 2014.02.03
[ JSTL 문법 정리 ]  (0) 2011.01.07
JSPF 를 이용한 INCLUDE 설명  (5) 2010.05.03
[펌] MINE TYPE 정보  (0) 2010.02.18
POST방식 헤더 값에 대한 정보  (1) 2009.11.23
반응형
MIME-Type Description File Extension
application/acad AutoCAD drawing files dwg
application/clariscad ClarisCAD files ccad
application/dxf DXF (AutoCAD) dxf
application/msaccess Microsoft Access file mdb
application/msword Microsoft Word file doc
application/octet-stream Uninterpreted binary bin
application/pdf PDF (Adobe Acrobat) pdf
application/postscript PostScript, encapsulated PostScript, ai, ps, eps
Adobe Illustrator
application/rtf Rich Text Format file rtf rtf
application/vnd.ms-excel Microsoft Excel file xls
application/vnd.ms-powerpoint Microsoft PowerPoint file ppt
application/x-cdf Channel Definition Format file cdf
application/x-csh C-shell script csh csh
application/x-dvi TeX dvi dvi dvi
application/x-javascript JavaScript source file js
application/x-latex LaTeX source file latex
application/x-mif FrameMaker MIF format mif
application/x-msexcel Microsoft Excel file xls
application/x-mspowerpoint Microsoft PowerPoint file ppt
application/x-tcl TCL script tcl
application/x-tex TeX source file tex
application/x-texinfo Texinfo (emacs) texinfo, texi 
application/x-troff troff file t, tr, roff t, tr, roff
application/x-troff-man troff with MAN macros man 
application/x-troff-me troff with ME macros me
application/x-troff-ms troff with MS macros ms
application/x-wais-source WAIS source file src
application/zip ZIP archive zip
audio/basic Basic audio (usually m-law) au, snd
audio/x-aiff AIFF audio aif, aiff, aifc
audio/x-wav Windows WAVE audio wav 
image/gif GIF image gif
image/ief Image Exchange Format file ief
image/jpeg JPEG image jpeg, jpg jpe 
image/tiff TIFF image tiff, tif
image/x-cmu-raster CMU Raster image ras
image/x-portable-anymap PBM Anymap image format pnm
image/x-portable-bitmap PBM Bitmap image format pbm
image/x-portable-graymap PBM Graymap image format pgm
image/x-portable-pixmap PBM Pixmap image format ppm
image/x-rgb RGB image format rgb
image/x-xbitmap X Bitmap image xbm
image/x-xpixmap X Pixmap image xpm
image/x-xwindowdump X Windows Dump (xwd)  xwd
multipart/x-gzip GNU ZIP archive gzip
multipart/x-zip PKZIP archive zip
text/css Cascading style sheet  css
text/html HTML file html, htm
text/plain Plain text txt 
text/richtext MIME Rich Text rtx
text/tab-separated- values Text with tab-separated values tsv
text/xml XML document xml
text/x-setext Struct-Enhanced text  etx
text/xsl XSL style sheet xsl
video/mpeg MPEG video mpeg, mpg, mpe 
video/quicktime QuickTime video qt, mov
video/x-msvideo Microsoft Windows video avi
video/x-sgi-movie SGI movie player format movie 


출처 : http://luna79.tistory.com/15
반응형

'Program > JSP' 카테고리의 다른 글

2차 도메인 Cookie 공유  (0) 2014.02.03
[ JSTL 문법 정리 ]  (0) 2011.01.07
JSPF 를 이용한 INCLUDE 설명  (5) 2010.05.03
JSP에서 Servlet 이외의 URL 접급 차단법  (0) 2010.03.05
POST방식 헤더 값에 대한 정보  (1) 2009.11.23

+ Recent posts