Just pass it as an argument to your function
BTW, you already have a String argument there but you don't use it.
It would be even better to put that function in a separate class instead of
in the page itself.
If you want to do the same check in another page, you can reuse the class,
but you cannot reuse the function declared in the page.
<%
String name = "abcd"
if checkName(name){ .....
%>
.
.
<%!
public boolean checkName(String str){
boolean validity = false;
if(str.equals("nishit"){ //want to use "name" from above defined
scriplet tags
validity = true;
}
return validity;
}
%>
Geert Van Damme
> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Nishit Trivedi
> Sent: dinsdag 6 maart 2001 23:32
> To: [EMAIL PROTECTED]
> Subject: using variable defined within <% %> in <%! %>
>
>
> 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"){ //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
>
===========================================================================
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