• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

registeration process logic

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic