Recommended resources for understanding sequence of events in CSP applications

I have inherited a web-based database application and I'm having a hard time understanding the sequence of events when CSP pages are opened.  I have very limited web development experience.

Can anyone recommend a good resource for explaining this?  I have already gone through the Cache Cinema tutorial and the Cache CSP documentation.

Among other things, I don't understand when the OnPreHTTP method is invoked, when it is needed, and what belongs in there.  But, my misunderstanding is more basic than that -- I don't really understand the sequence of events for when a web page is loaded and the user interacts with it. 

  • 0
  • 0
  • 146
  • 3
  • 1


I try a simple explanation and you should try to find some docs on HTTP:
So I leave out several steps in between to illustrate the basic actions.

your browser sends a request

GET /index.html HTTP/1.1

and if it is successful the server replies

HTTP/1.1 200 OK
Date: Mon, 23 May 2005 22:38:34 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 138
Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT
Server: Apache/ (Unix) (Red-Hat/Linux)
ETag: "3f80f-1b6-3e1cb03b"
Accept-Ranges: bytes
Connection: close

  <title>An Example Page</title>
  Hello World, this is a very simple HTML document.

The highlighted part between HTTP and your first <html> is prepared or modified  if not default in OnPreHTTP().
It has to be ready BEFORE sending the reply. 

The delimiter between HTTP part and the content transmitted is just an empty line.
The closing is 2 empty lines.

For the items you can influence see class %CSP.Response

Thank you! 

In some of the CSP pages in my application, there is code in the OnPreHTTP method to process a button-click or form submit, but in other pages, the form processing is done outside of the OnPreHTTP method.

Does it matter whether or not the form processing code is in the OnPreHTTP method?  Are there reasons why the form processing should or should not go in the OnPreHTTP method?

Code placement depends on what you're trying to do and when: if processing the event from javascript (ajax call) then your code must be separate from OnPreHTTP(); if processing on the server (after page submit) then your code should be in OnPreHTTP() or called from it (this last part depends on your coding style - jam everything in a single method or separate things in multiple smaller methods)

In simple terms (as Robert pointed out) , OnPreHTTP needs to handle any processing the server must perform prior to "displaying"/"printing" the page on the browser.