Ah, I see your question now.
JSP declarations differ from plain scriptlets in that they're translated
into class variables and/or class methods, i.e., they're "global" in the
JSP. If you understand servlets, declarations are converted into variables
and methods outside of the JSP's service() method, while scriptlets are all
part of the service() method.
As such, a declaration does not have access to any of the JSP implicit
objects (request, out, page, etc.) unless they're passed in to a method
declaration as a parameter. Scriplets and expressions are both part of the
service() method, where they have access to the local request, out, and
other implicit objects that only exist within the scope of the JSP's
service() method.
So, you can declare a variable like so:
<%! Object obj = new Object(); %>
Which will make a single instance of that variable, no matter how many
requests the JSP handles over time.
But if you declare the variable as a scriptlet, you'll end up with a new one
being created every time the service() method is invoked -- i.e., for every
request:
<% Object obj = new Object(); %>
Scott
> -----Original Message-----
> From: Marc Garrett [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, March 15, 2001 10:30 PM
> To: JRun-Talk
> Subject: Re: how to set variable to value of request?
>
>
> Thanks Scott, that's what I was looking for. What was confusing me was
> this -- why is your code right, but the following code wrong:
>
> <%! String varName...
>
> Regards,
>
> Marc Garrett
>
> ----- Original Message -----
> From: "Scott Stirling" <[EMAIL PROTECTED]>
> To: "JRun-Talk" <[EMAIL PROTECTED]>
> Sent: Thursday, March 15, 2001 9:32 PM
> Subject: RE: how to set variable to value of request?
>
>
> > <% String varName = request.getParamter("param"); %>
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists