Guest Book
What people have said about the book:
It was readable and informative. I don’t use the product or write apps, so it’s more than I can fully understand. That said, it reads well and from what you indicated it fills a niche that needs filled.
Stephen Wargo (Yes, the author's brother) |
|
|
|
|
In chapter 8, I showed a sample Domino application that dumped the contents of a browser request's HTTP Header values back to the BlackBerry browser. The purpose of the application was to illustrate what a BlackBerry device looked like to the web server (by showing the HTTP Header values that could be read by the web server). A web server could read any of these header values and use the information to determine information about the requesting device.
The page that's displayed by the application is the output generated by a LotusScript agent embedded in a Domino database. To open the page, place the attached Domino database and place it on a Domino server that is running the HTTP task. Open the desktop or BlackBerry browser and enter the following URL:
http://server-name/hdr_dump.nsf/dumpheaders?openagent
where server-name is the name of the Domino server hosting the database. When you open the page in the BlackBerry browser, you will see a screen similar to the one shown below:

And here is the code for the Header Dump agent that generated the page:
Option Public
Option Declare
Sub Initialize
'Some Notes objects we'll use on the form
Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim tmpItem As NotesItem
Dim tmpName As NotesName
Dim tmpVar As Variant
'Other objects
Dim webDBName As String
Const slash = |/|
'I did this to suppress the header generated by Domino
Print "Content-Type:text/html"
Set db = s.CurrentDatabase
Set tmpName = New NotesName(db.Server)
'Get a handle to the document
Set doc = s.DocumentContext
webDBName = slash & db.FilePath & slash
Call ReplaceSubstring(webDBName, | |, |+|)
Call ReplaceSubstring(webDBName, |\|, |/|)
'Print the HTML page
Print |<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">|
Print |<html>|
Print |<head>|
Print |<title>Browser Information: Headers for | & tmpName.Common & |</title>|
Print |<META HTTP-EQUIV="Pragma" CONTENT="no-cache">|
Print |<link rel="stylesheet" type="text/css" href="/| & webDBName & |standard.css?OpenCssResource">|
Print |</head><body><br />|
'Print the page's header
Print |<h2>Browser Request Headers</h2><hr />|
Print |The following list contains all of the Header values passed with the browser request to the Domino server.<br />|
'Print the page's content
Forall x In doc.Items
Print |<H2>| & x.Name & |</h2>|
Forall y In x.values
Print |<p>| & y & |</p>|
End Forall
End Forall
'Now print the end of the page
Print |<br /><hr />Copyright © 2009 John M. Wargo|
Print |</body></html>|
End Sub
Sub ReplaceSubString ( string_value As String, search_string As String, replace_string As String )
Dim search_Len As Integer
Dim new_string As String
Dim pos As Integer
Dim previous_position As Integer
new_string = ""
pos = Instr ( Ucase (string_value), Ucase (search_string) )
previous_position = 1
If ( pos = 0 ) Then
Exit Sub
End If
search_len = Len ( search_string )
Do While ( pos )
new_string = new_string + Mid$ ( string_value, previous_position, pos - previous_position ) + replace_string
previous_position = pos + search_len
pos = Instr ( previous_position, Ucase (string_value), Ucase (search_string) )
Loop
string_value = new_string + Right$ ( string_value, Len ( string_value ) - previous_position + 1)
End Sub
The attached database also contains components (forms and agents) that dump additional information about the user agent (the browser) connecting to the server:
- @BrowserInfo - all of the possible values returned by the Domino @BrowserInfo function.
- CGI Variables - These variables are the Domino server's internal reference to the parameters available to a CGI application. This is similar to what the Header Dump agent generates, but just illustrates another way a Domino web application can determine information about the connecting device.
- JavaScript information - The BlackBerry browser supports several BlackBerry-specific JavaScript objects that can use used in a web page to determine information about the device. RIM changed the way the JavaScript objects worked in BlackBerry Device Software 4.6, so this option will only work on devices running earlier versions of the Devcie Software (I didn't get around to updating it in time to publish it).
|
|
|