aspose file tools*
The moose likes JSP and the fly likes registeration process logic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "registeration process logic" Watch "registeration process logic" New topic
Author

registeration process logic

hesham katon
Ranch Hand

Joined: Dec 18, 2002
Posts: 82
Hello All

I am doing registeration process
there is 2 tables
1. client
2. serial (has a field with last client no.)

I want to add new client in client table , its number is last client no. +1

what i already did as follows

1. html form for user information
2. jsp confirmation page (gets data from the previous page)
it access serial table and gets last client no.
it has submit button that add new client to client table
3. jsp page to modify serail table with the new customer no

this works fine when single user test it

but when many user try to register an error happen
because the second step is wrong , may be 2 or more clients gets the same last clien no. , and then when they submit a duplication may happen

i want to know a better logic for this problem

Thank you all in advance


Hesham Katon<br />SCJP 1.2<br />SCWCD 1.4<br />Better to light a candle than to curse the darkness
Rahul Kappor
Greenhorn

Joined: Nov 10, 2007
Posts: 12
I am not sure what database you are using but I would recommend that use sequence (Oracle has sequence) to get the next number before you insert into the table. Sequence will always assign next available number to new request even when there are concurrent request to db at the same time. Oracle will handle that far you.

Your issue is that there could be multiple clients who can access the page that assign the next number at the same time.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

Originally posted by hesham katon:

2. jsp confirmation page (gets data from the previous page)
Not the best of ideas. JSP should be used for views and not for processing. You might find this article helpful.

3. jsp page to modify serail table with the new customer no
See above.

this works fine when single user test it

Most often, when things go awry when multiple users start using a web app it's because of thread safety issues.

Be sure that you have no instance variables in your servlets or JSPs. The use of <%! %> on a JSP is the easiest way to get yourself into big trouble.

[ November 11, 2007: Message edited by: Bear Bibeault ]
[ November 11, 2007: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: registeration process logic
 
Similar Threads
data mixup for two responses
Common Functionality in all the pages.
URGENT Help Needed ...!!
Record Locking in multi-user
How to update Session variable with Form Data ?