473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Server-side validation and cacheable forms

Hello everybody. I'm writing a Perl script managing forms submissions
but encounter some difficulty on a step.

1) User submits a form (using POST method). The page being declared as
cacheable with "Cache-Control: max-age=10000".

2) The server-script receives the data, parse and validate them.

2b) If something sounds wrong, it returns a page containg an explicit
error message and a link going to previous cached form (using javascript
history.back).

2c) If all sounds right, it returns a modifiable preview (a web page
containing a formatted output and a pre-filled form in case he wants to
change something). This page is also declared cacheable as the first
one. Here, user can submit the preview as is, or generate a new
modifiable preview.

3) We renew the serial of steps #2. The problem is that, here (after
step #3), if we fall in case #2b, the link doing history.back return to
a non cached page (in spite of "Cache-Control: max-age=10000" in that
page) !

From this constat, I have two questions to ask you :

- Why my first form is well cached (1 -2 -2b -1 works) while next
ones are not (2c -2 -2b -2c doesnt' work : form is not in cache)

- Does my strategy about "what to do when server-side validation find
something wrong ?" is a good one (i.e. provide an history.back(-1)) or
should I go to another direction ?

May 29 '07 #1
3 2753
Yohan Blurp wrote:
Hello everybody. I'm writing a Perl script managing forms submissions
but encounter some difficulty on a step.

1) User submits a form (using POST method). The page being declared as
cacheable with "Cache-Control: max-age=10000".

2) The server-script receives the data, parse and validate them.

2b) If something sounds wrong, it returns a page containg an explicit
error message and a link going to previous cached form (using javascript
history.back).

2c) If all sounds right, it returns a modifiable preview (a web page
containing a formatted output and a pre-filled form in case he wants to
change something). This page is also declared cacheable as the first
one. Here, user can submit the preview as is, or generate a new
modifiable preview.

3) We renew the serial of steps #2. The problem is that, here (after
step #3), if we fall in case #2b, the link doing history.back return to
a non cached page (in spite of "Cache-Control: max-age=10000" in that
page) !

From this constat, I have two questions to ask you :

- Why my first form is well cached (1 -2 -2b -1 works) while next
ones are not (2c -2 -2b -2c doesnt' work : form is not in cache)
- Does my strategy about "what to do when server-side validation find
something wrong ?" is a good one (i.e. provide an history.back(-1)) or
should I go to another direction ?
Go another direction.

1) The user goes to your form handling CGI script. The script sees that
there is no data posted, so it sends the empty form to the browser.

2) The user submits the form. The CGI script looks for a particular
field (probably a hidden field value) and determines that this is an
initial submission of the form.

2b) If something is wrong, the form is returned to the user with an
error message at the top of the page, and all of his previous data
filled in.

2c) If all sounds right, the form is returned with all of the values
filled in. Here, user can submit the preview as is, or generate a new
modifiable preview.
3) The user submits the form. The CGI script looks for a particular
field (probably a hidden field value) and determines that this is an
subsequent submission of the form. The script also determines which
submit button (preview or post) was clicked. If something is wrong,
return to step 2b. If Preview was clicked, return to 2c. If Post was
clicked, and everything is OK, the data is posted.

history.back(-1) and what is or is not cached are non-issues since the
script is serving the form from scratch every time.

Modules that will make life easier are HTML::Template (to create the
form) and HTML::Entities (to prepare the data to be inserted into the form).

May 30 '07 #2
In article <jO******************************@comcast.com>,
sb****@scottbryce.com says...
Go another direction.
I'm afraid you're right :-( My main problem is that I have to revamp
this very long script (10,000 lines), which had not any preview in its
first version and worked with this history.back feature, and it will be
not so easy.

Also, the first difficulty I see this morning and after reading of your
post is about this preview. On preview stage (your step 3c) the page
shows the formatted previous and a form to allow to edit-it : I think I
will have not any problem to display this reedition form again in case
of validation error, but it will be harder for the preview itself which
contains image, text, special look n' feel, etc... This knowing I don't
see anything like display_preview() in code ; and more, I suspecte the
displayed imgage doesn't exist anymore on server after preview
display...

I foresee some days and weeks of fun !
May 30 '07 #3
In article <jO******************************@comcast.com>,
sb****@scottbryce.com says...
Go another direction.
I'm afraid you're right :-( My main problem is that I have to revamp
this very long script (10,000 lines) and it will be
not so easy.

Also, the first difficulty I see this morning and after reading of your
post is about this preview. On preview stage (your step 3c) the page
shows the formatted previous and a form to allow to edit-it : I think I
will have not any problem to display this reedition form again in case
of validation error, but it will be harder for the preview itself which
contains image, text, special look n' feel, etc... This knowing I don't
see anything like display_preview() in code ; and more, I suspecte the
displayed imgage doesn't exist anymore on server after preview
display...

I foresee some days and weeks of fun !
May 30 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Phil | last post by:
I am using a Pascal like language (Wealth-Lab) on W2K and call this server: class HelloWorld: _reg_clsid_ = "{4E797C6A-5969-402F-8101-9C95453CF8F6}" _reg_desc_ = "Python Test COM Server"...
6
by: Nathan Sokalski | last post by:
I want to set up SQL Server on Windows XP Pro so that I can use the database capabilities of ASP and IIS. I am probably using some incorrect settings, but I am not sure what they are. Here is what...
9
by: Grim Reaper | last post by:
My work let me put SQL Server 7.0 Enterprise Edition on my laptop. I have never setup a server from the beginning, so I am a little new at creating server groups. Alright, I am trying to create...
0
by: Chris Halcrow | last post by:
Hi I've spent ALL DAY trying to re-install SQL Server 2000 on Windows XP. I continually get the error 'cannot configure server' just at the end of the installation. I've tried the following: ...
0
by: Zorba.GR | last post by:
IBM DB2 Connect Enterprise Edition v8.2, other IBM DB2 (32 bit, 64 bit) (MULTiOS, Windows, Linux, Solaris), IBM iSoft Commerce Suite Server Enterprise v3.2.01, IBM Tivoli Storage Resource Manager...
22
by: EP | last post by:
When running my asp.net hosting service (asp.net without IIS), on server 2003 with IIS not installed, I get the following when trying to process a request. "System.DllNotFoundException: Unable to...
2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
4
by: coosa | last post by:
Hi, I was installing SQL Server on my machine and during installation my PC freezed. It happens frequently on my machine. So i tried after restarting to install it again and since then i always...
1
by: Peter | last post by:
I've purchased VS.NET 2005 Standard and have tried to install SQL Server 2005 Express, but get the following error in the error log. Please could someone help me.... Microsoft SQL Server 2005...
14
by: Developer | last post by:
Hello All, i have recently installed VS2005 and was trying to install SQL sever 2000. I have Win XP' SP2. But when I tried installing, it only installed client tools and not the database. Can...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.