File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes When are scriplets executed? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "When are scriplets executed?" Watch "When are scriplets executed?" New topic

When are scriplets executed?

Ian Whitelaw

Joined: Mar 30, 2000
Posts: 13
I have another problem with my JSP/bean (shown below). My understanding of jsp scriplets (as opposed to declarations and expressions) is that they are executed when the user submits a request, but not when the JSP is first loaded.
If so, why does the processRequest() method on my bean seem to be executed when the page first comes up?
The JSP:

The bean:
Tony Alicea

Joined: Jan 30, 2000
Posts: 3226
I had the same question some time ago and I found out that the scriptlets are always executed when the JSP is.
The first time, you may want to check for nulls depending on the application. My observation is that they always get executed when the page is processed. And that you may want a different result the times after the first

Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
I agree. Here's the link:
subject: When are scriplets executed?
It's not a secret anymore!