• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

User Defined Functions in JSP

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
Can we make use of User Defined functions In JSP as we do in ASP ? If yes tell me the Syntax and how to call the function ?
 
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hari,
I dont have knowledg of ASP,but this is how u can define and call function in jsp
[B]<%![B]
public void myfunction()
{
}
%>
<%
myfunction();
%>
Hope this helps you
Cheers
Praful
 
Hari Haran
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Praful Thakare:
Hari,
I dont have knowledg of ASP,but this is how u can define and call function in jsp
[B]<%![B]
public void myfunction()
{
}
%>
<%
myfunction();
%>
Hope this helps you
Cheers
Praful



hi ,This is how i tried it . I had only this code in my jsp file .
<%!
public void myfunction()
{
%>
<%="inside function "%>
<%
}
%>
<%
myfunction();
%>

but it gives the following error:
Error: 500
Internal Servlet Error:
org.apache.jasper.JasperException: Unable to compile class for JSPC:\jakarta-tomcat-3.2.4\work\localhost_8080%2Fppfp\_0002fjsp_0002fWebSite_0002ftest_0002fTestFunction_0002ejspTestFunction_jsp_0.java:22: '}' expected.
{
^
C:\jakarta-tomcat-3.2.4\work\localhost_8080%2Fppfp\_0002fjsp_0002fWebSite_0002ftest_0002fTestFunction_0002ejspTestFunction_jsp_0.java:25: Statement expected.
static {
^
C:\jakarta-tomcat-3.2.4\work\localhost_8080%2Fppfp\_0002fjsp_0002fWebSite_0002ftest_0002fTestFunction_0002ejspTestFunction_jsp_0.java:76: 'try' without 'catch' or 'finally'.
out.write("\r\n");
^
C:\jakarta-tomcat-3.2.4\work\localhost_8080%2Fppfp\_0002fjsp_0002fWebSite_0002ftest_0002fTestFunction_0002ejspTestFunction_jsp_0.java:83: Type expected.
} catch (Exception ex) {
^
4 errors
 
Sheriff
Posts: 67581
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch Hari!
You'll find this forum a great place to seek help on JSP pages, and there aren't many rules you'll have to worry about, but one is that proper names are required. Please take a look at the JavaRanch Naming Policy and change your display name to match it.
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.
Thanks!
bear
JSP Forum Bartender
[ December 12, 2003: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 1880
Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
=====
<%!
public void myfunction()
{
%>
<%="inside function "%>
<%
}
%>
<%
myfunction();
%>
======
u can not mix both declaration & expressions & scriplets...see u did not complete ur declaration part,,but u include one expreassion...
 
Shiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic