ASP에서는 (VBScript) 큰 따옴표를 마음대로 출력할 수가 없다.

%>"<% 이런식으로 ASP 태그를 닫아서 출력해주거나
chr(34) 함수를 이용하여 캐릭터 코드를 변환시켜서 출력해주는 수 밖에 없다.


#2008.10.28 추가

큰 따옴표를 "" 두개로 묶어주면 된다. MSSQL도 string 안에 작은 따옴표를 사용하고 싶다면 '' 두개 붙여주면 된다.
str = "<a href=""/"">home</a>"
이런식이다.



ASP Encode/Decode Functions

Methods for encoding and deconding text in various formats.


Server.URLEncode

Used for encoding data that will be passed via a querystring variable. A querystring variable is anything following the question mark (?) in the URL (location) field of your browser. You create querystring variables when you perform a redirect or build a hyperlink to another page on your site.

<a href="page2.asp?name=Joe+Schmoe">here</a>
<%
Response.Redirect "page2.asp?ID=3"
%>

In the example above, the hyperlink contains a variable named "name" which has a value of "Joe Schmoe" (the space is encoded as "+") In the Response.Redirect statement, we have a querystring variabled named "ID" with a value of 3. To perform a URL encode on a variable (for purposes of passing this variable to another page) use the following:

<a href="page2.asp?name=<%= Server.URLEncode(sName) %>">
here</a>
<%
Response.Redirect "page2.asp?ID=" &_
Server.URLEncode(nID)
%>

URLDecode

For some reason, Microsoft did not include a URL decode function with Active Server Pages. Most likely, this was because the decoding of querystring variables is done automatically for you when you access the querystring object:

<%= Request.QueryString("name") %>

For those of you who are desperately in need of this function:

' -----------------------------------------
' URL decode to retrieve the original value

Function URLDecode(sConvert)
Dim aSplit
Dim sOutput
Dim I
If IsNull(sConvert) Then
URLDecode = ""
Exit Function
End If

' convert all pluses to spaces
sOutput = REPLACE(sConvert, "+", " ")

' next convert %hexdigits to the character
aSplit = Split(sOutput, "%")

If IsArray(aSplit) Then
sOutput = aSplit(0)
For I = 0 to UBound(aSplit) - 1
sOutput = sOutput & _
Chr("&H" & Left(aSplit(i + 1), 2)) &_
Right(aSplit(i + 1), Len(aSplit(i + 1)) - 2)
Next
End If

URLDecode = sOutput
End Function

Server.HTMLEncode

This useful built-in function is very useful for encoding text that should be displayed in a form input. By "form input" we mean a web form control such as a text input, select or textarea control.

You may have noticed that certain characters cause the HTML on your web form to be interpretted incorrectly. Specifically, the HTML tag characters "<" and ">" can have this effect as well as the quote character (") which is used to encapsulate values.

<input type="text" value="<%= Server.HTMLEncode(sValue) %>">

<textarea name="sample" width=38 height=10>
<%= Server.HTMLEncode(sValue) %>
</textarea>
This simple value shows you how easy it is to safely include any value within a web form control.

HTMLDecode

Just like with the URLDecode function described previously, Microsoft, in its infinite wisdom decided not to include an HTMLDecode function with their Server component. It is a relatively simple matter to decode this test data (although I haven't had a need to do this so far.) For completeness sake, here is an HTMLDecode function you may use:

Function HTMLDecode(sText)
Dim I
sText = Replace(sText, "&quot;", Chr(34))
sText = Replace(sText, "&lt;" , Chr(60))
sText = Replace(sText, "&gt;" , Chr(62))
sText = Replace(sText, "&amp;" , Chr(38))
sText = Replace(sText, "&nbsp;", Chr(32))
For I = 1 to 255
sText = Replace(sText, "&#" & I & ";", Chr(I))
Next
HTMLDecode = sText
End Function

출처 : ASP Encode/Decode Functions
예전에는 php에서 이전페이지에서 넘어온, get이나 post로 넘어온 값을 가지고 처리해할 때,

바로 변수이름을 주거나 $_POST 배열을 그냥 읽었다.

예를 들어 name=janghyuk 이란 값을 post로 넘기게 되면,

$name 으로도 접근이 가능했었다. 하지만 이건 보안상 위험한 문제이고,

$_POST["name"] 으로 받는 것이 좋으나, 있는지 없는지 체크를 하지 않고 받으면

"" , empty string 으로 받아지게 된다.


아예 post로 해당 값이 들어왔는지 체크를 하기 위해서,

if( array_key_exists( 'name', $_POST ) ) 로 체크하면 확실히 넘어왔는지 여부를 가릴 수 있다.
mysql에는 password()라는 내장함수가 있다.
하지만 mssql에는 다른 함수가 있다.

== 암호화 하여 튜플 삽입하기 ==
INSERT INTO MEMBERSHIP values('rE', pwdencrypt('1234'))

== 암호화된 튜플 검색하기 ==
SELECT UID FROM MEMBERSHIP WHERE 1 = pwdcompare('1111', PASSWORD)
// Return one more UID or nothing

SELECT pwdcompare('1111', PASSWORD) FROM MEMBERSHIP WHERE UID = 'rE'
// Return [0 | 1]


성공을 위한 21가지 조언 (21 Suggestions for Success)
by H. Jackson Brown Jr.
  1. 적절한 사람(right person)과 결혼해라. 이 한번의 결정은 당신의 행복, 혹은 불행의 90%를 결정할 것이다.
  2. 당신이 즐겁게 할 수 있고, 당신의 재능과 시간이 아깝지 않은 일을 해라.
  3. 사람들의 기대보다 더 많이, 즐겁게 줘라.
  4. 당신은 당신이 아는 사람 중 가장 긍정적이고 활기찬 사람이 되어라.
  5. 당신 스스로와 다른 사람들을 용서하여라.
  6. 관대하라.
  7. 감사하는 마음을 가져라.
  8. 인내하고, 인내하고, 인내하라.
  9. 심지어 가장 적은 월급에 대하여도 돈을 아낄 수 있도록 자제심을 길러라.
  10. 당신이 받고 싶은 대우로 남들을 대하라.
  11. 지속적인 개선을 위하여 노력하라.
  12. 우수함(quality)을 위하여 노력하라.
  13. 행복은 소유나 권력, 혹은 특권이 아니라 당신이 사랑하고 존경하는 사람들과의 관계에서 온다는 것을 기억하라.
  14. 충성스러우라.
  15. 진솔하라.
  16. 스스로 (변화를) 시작할 수 있는 사람이 되어라.
  17. 때로는 틀린다 할지라도, 결단력을 갖추어라.
  18. 남들을 탓하지 말고, 당신 삶의 모든 영역에 있어서 책임감을 지녀라.
  19. 대담하고 용감해져라. 훗날 인생을 돌이켜보면, 한 것들 보다는 안해본 것들에 대하여 후회하게 마련이다.
  20. 당신이 사랑하는 사람들을 잘 대해주어라.
  21. 당신의 어머니가 자랑스러워 하지 않을 일은 삼가라.

원문:
  1. Marry the right person. This one decision will determine 90% of your happiness or misery.
  2. Work at something you enjoy and that's worthy of your time and talent.
  3. Give people more than they expect and do it cheerfully.
  4. Become the most positive and enthusiastic person you know.
  5. Be forgiving of yourself and others.
  6. Be generous.
  7. Have a grateful heart.
  8. Persistence, persistence, persistence.
  9. Discipline yourself to save money on even the most modest salary.
  10. Treat everyone you meet like you want to be treated.
  11. Commit yourself to constant improvement.
  12. Commit yourself to quality.
  13. Understand that happiness is not based on possessions, power or prestige, but on relationships with people you love and respect.
  14. Be loyal.
  15. Be honest.
  16. Be a self-starter.
  17. Be decisive even if it means you'll sometimes be wrong.
  18. Stop blaming others. Take responsibility for every area of your life.
  19. Be bold and courageous. When you look back on your life, you'll regret the things you didn't do more than the ones you did.
  20. Take good care of those you love.
  21. Don't do anything that wouldn't make your Mom proud.


출처: http://dotty.org/2698906
에러 핸들링을 하는 try ... catch (... finally) 문은 ASP에 없다. 엄밀히 말하면 VBscript엔 없다.


하지만 방법이 있다.

On Error Resume Next '// ERROR CHECKING

If err <> 0 Then '// ERROR OCCURRED
 '// 에러처리
End If

On Error Goto 0 '// Clear Errors
On Error Resume Next '// NEW ERROR CHECKING


BLOG main image
by 장혁닷컴

공지사항

카테고리

분류 전체보기 (15)
Web2.0_ (0)
게시판 (0)
Web (10)
자전거여행 (0)
Excel (1)
라임라이트 (0)
문화생활 (0)

글 보관함

달력

«   2008/06   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          
Total : 3,740
Today : 0 Yesterday : 0