• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bypass Code?

 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65128
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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: 832
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 65128
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic