• 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

Bypass Code?

 
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a method call on one line and immediately afterwards I have a different method call. The first goes and reads a record in and assigns it to a variable and the other writes. In JSP is it possible for the second method to be hit before the first has finished? If so, how can I avoid this from happening? The method calls are third party. Thanks.

RH
 
Sheriff
Posts: 67747
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
No. JSPs are translated into servlets for execution on the server by a JVM. All the rules of Java apply. Which means that statements will be executed in sequence.
 
Rob Hunter
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear,
The reason why I'm asking is that it appears the lock held by the read has not been released before the write method call directly after it. Have you encountered anything like this? I know you said sequential processing just wondering about a database lock sticking around long enough for the write to complain it's already locked. Is there a straight up way to sleep or nap for a small amount of time in JSP to test this theory out? Thanks again.

Rob
 
Bear Bibeault
Sheriff
Posts: 67747
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
Not to be persnickety, but doing DB access in a JSP is an egregious violation of all best practices and patterns. And a pain in the rear to debug.

My advice is to factor all that code out of the JSP into a Java class that you can test stand-alone. A much easier scenario to debug.

Once you you've got things working there, you can either connect to this code via a bean in the page (poor, but better than code in the JSP), or in a servlet controller for the page (much better) all under Java control.
 
reply
    Bookmark Topic Watch Topic
  • New Topic