Manage Learn to apply best practices and optimize your operations.

Urldecoding Strings From The Web

Playing in Script can be a lot of fun over the web, and integrating flat HTML
with the domino system can have it's advantages.
I've noticed that some browser's when they post a form to an agent then encode
the content string, so I have a routine for decoding the strings.
if you were to have a form in a HTML file you can submit it to an agent.
eg.
&LTform method="POST" action="http://dominoserver/notesdb.nsf/agent?OpenAgent"
name="test" >
&LTinput type="text" name="username">
&LTinput type="password" name="password">
</form>
&LTa href="javascript:document.test.submit()">submit</a>
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument

Dim strHTTPContent As String
Dim strUsername As String
Dim strEncChar As String
Dim strSrcstr As String

Dim lngHTTPLength As Long
Dim lngHTTPPos As Long

Dim intPerChar As Integer

Set db = session.CurrentDatabase
Set doc = Session.DocumentContext ' Get the submitted web doc... this is
stored in RAM on domino

strHTTPContent = Cstr(doc.Request_Content(0)) ' Grab the form contents.

'UNEncode call to the function.
strHTTPContent = HTTPDecode(strHTTPContent)

lngHTTPLength = Len(strHTTPContent)
lngHTTPPos = Instr(strHTTPContent, "username=")
If (lngHTTPPos) Then
strUsername = Right(strHTTPContent, lngHTTPLength - lngHTTPPos - 8)
lngHTTPPos = Instr(strUsername, "&")
If (lngHTTPPos) Then strUsername = Left(strUsername, lngHTTPPos - 1)
End If
' strUsername will contain the contents of the username field on the HTML page.
' you can apply the same to getting the value from the password field .
' from here on it's up to you how you apply it to your own application.

Print strUsername
End Sub

' Paste the function in the declarations

Function HTTPDecode(strHTTP As String) As String
Dim strOut As String
Dim intPos As Integer

strOut = strHTTP
intPos = Instr(strOut, "%")
While (intPos)
strOut = Left(strOut, intPos - 1) + Chr(Val("&H" + Mid(strOut, intPos + 1,
2))) + Right(strOut, Len(strOut) - (intPos + 2))
intPos = Instr(strOut, "%")
Wend

HTTPDecode = strOut
End Function
This was last published in November 2000

Dig Deeper on Domino Resources - Part 7

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchExchange

SearchContentManagement

Close