Put your function definitions in a declarations section:

<%!
String validateStr(int length,String str)
{
...
}
%>

The '!' tells the JSP engine to put the code outside the _JspService
function.  All code in the <%...%> delimiters will be put in the _JspService
function.  BTW, <%!...%> must contain complete definitions not code
fragments as with <%...%>.

Dana H. P'Simer, Jr.
x7547
[EMAIL PROTECTED]
[EMAIL PROTECTED]


> -----Original Message-----
> From: satya b [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, February 29, 2000 11:32 PM
> To: [EMAIL PROTECTED]
> Subject: How to call a method in JSP !!!!
>
>
> Hi gueys,
>
> I am converting servlets to jsp.Actually in servlets
> we will define class and methods.In case of JSP we
> won't define classes,in that case how to call a method
> in JSP. I got the error msg as ......
> c:\j2sdkee1.2\repository\RICH-S\web\ganrt\_0005cRegister_0002e
> jspRegister_jsp_0.java:390:
> Statement expected.
>                 public String validateStr(int
> length,String str)
>                 ^
> c:\j2sdkee1.2\repository\RICH-S\web\ganrt\_0005cRegister_0002e
> jspRegister_jsp_0.java:404:
> Class or interface declaration expected.
>                    }catch (Exception ex) {
>
>
> My code is like this:
> -----------------------
>         int retValue=
> custQuery.insertCustomer(intCustId,validateStr(30,firstname),v
> alidateStr(30,lastname),validateStr(8,sex),validateStr(10,age)
> ,validateStr(30,income),validateStr(30,profession),validateStr
> (30,education),validateStr(10,familysize),validateStr(2,countr
> y),validateStr(50,company),validateStr(50,jobtitle),validateSt
> r(80,officemailaddress),validateStr(50,officemailaddress1),val
> idateStr(30,officecity),validateStr(30,officestate),validateSt
> r(20,officeZip),validateStr(10,officeAreacode),validateStr(20,
officephoneno),validateStr(20,officefax),validateStr>
(80,officeEmailaddress),validateStr(80,Homemailaddress),valida
> teStr(50,Homemailaddress1),validateStr(30,Homecity),validateSt
> r(30,Homestate),validateStr(20,HomeZip),validateStr(10,HomeAre
acode),validateStr(20,Homephoneno),validateStr(20,Homefax),validateStr>
(80,HomeEmailaddress),validateStr(80,personalhomepage),validat
> eStr(4,noofvisits),validateStr(32,lastvisit),validateStr(50,ip
address),validateStr(50,browser),dateofregistration,emailsent,v!
> alidateStr(1,inactivate),validateStr(1,load),dateloaded,valida
> teStr(10,birthyear));
>
> public String validateStr(int length,String str)
>         {
>              if(str!=null)
>              {
>                 if(str.length()>length)
>                 {
>                         System.out.println("Wrong Entry"+str);
>                         return "0";
>                 }
>                 else    return str;
>              }
>              else
>                          return "0";
>         }
>
> This method i had called so many times like this..But
> it is giving error as....
>
>
>
> So pls help me in this....
>
> Waiting for your solution.....
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
> ==============================================================
> =============
> To unsubscribe: mailto [EMAIL PROTECTED] with body:
> "signoff JSP-INTEREST".
> 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

PSimer, Dana.vcf

Reply via email to