Not Quite Correct.
I'll clarify :
The method / variable declared within the declaration tags i.e. <% !..... %>
become an instance method / variable of the compiled jsp servlet class.
Where as variables declared inside the scriptlets i.e. <%....%> become
_jspService method variables and their scope is limited to the _jspService
method. Also note that you cannot declare a method inside scriptlets because
in Java its not possible to declare one method inside the other.

To access the variable declared in the scriptlets from the instance method
declared within the declartion tags you would need to pass the _jspService
method variable to your instance method.

Nothing much to do with initialization,ect. as far as instance methods are
concerned. Though the jspInit method is related to initialization,ect.
Have a nice day.
With regards,
Sachin S. Khanna.
www.emailanorder.com

----- Original Message -----
From: dbg consulting <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 08, 2001 8:51 PM
Subject: Re: using variable defined within <% %> in <%! %>


> You are trying to access a variable that hasn't been declared yet.  The
<%!
> %> code gets generated and run during initialization.  The <% %> code is
RUN
> during http requests, AFTER initialization.  You are trying to access a
> "method" variable in an initialization process.  Remember, the JSP gets
> converted to a servlet.  If you aren't familiar with servlets you should
> acquaint yourself with them because that is the best way to become good
with
> JSP and understand issues like the one you are asking about.
>
> >From: Nishit Trivedi <[EMAIL PROTECTED]>
> >Reply-To: A mailing list about Java Server Pages specification and
> >     reference <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: using variable defined within <% %> in <%! %>
> >Date: Tue, 6 Mar 2001 17:32:18 -0500
> >
> >hi,
> >
> >how do i use the variable defined within scriplet tag( <% %> ) in
> >declarataion (<%! %>)?
> >
> >e.g
> >----------------------------------------------------
> ><%
> >   String name = "abcd"
> >%>
> >.
> >.
> ><%!
> >   public boolean checkName(String str){
> >     boolean validity = false;
> >     if(name.equals("nishit"){ file://want to use "name" from above
defined
> >scriplet tags
> >       validity = true;
> >     }
> >     return validity;
> >   }
> >%>
> >------------------------------------------
> >
> >can any body help me in this?
> >
> >Nishit Trivedi
> >Software Engineer
> >Planet Access Networks - An InSage Company
> >973-691-4704 X157
> >
>
>===========================================================================
> >To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> >JSP-INTEREST".
> >For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> >DIGEST".
> >Some relevant FAQs on JSP/Servlets can be found at:
> >
> >  http://java.sun.com/products/jsp/faq.html
> >  http://www.esperanto.org.nz/jsp/jspfaq.html
> >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to