Re: Newbie functions question
From: Ryan Stewart (zaphod_at_no.texas.spam.net)
Date: 01/14/04
- Next message: JDany: "Re: Java and MySql program example ?"
- Previous message: Piotre Ugrumov: "Tutorial JAVA-XML"
- In reply to: Stuart Palmer: "Re: Newbie functions question"
- Next in thread: Herman Timmermans: "Re: Newbie functions question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 14 Jan 2004 12:25:16 -0600
"Stuart Palmer" <tryandspamme@youcant.com> wrote in message
news:bu3gc3$2tk4$1@sp15en20.hursley.ibm.com...
*fixed top post*
> "Ryan Stewart" <zaphod@no.texas.spam.net> wrote in message
> news:PYKdnT1XuN51p5jdU-KYkQ@texas.net...
> > Actually, you can just put the method in the JSP:
> > <%!
> > private String testMethod(String str) {
> > String newString = str + " :: modified by method";
> > return newString;
> > }
> >
> > %>
> >
> >
> Thx Ryan,
> How would i call this function?
>
> <%=testMethod("Test");%>
>
> This comes up with an error for me.
>
> Many thanks as this looks like what I am after.
>
> Stu
Get rid of the semicolon or the equals. The <%= means an expression follows:
an expression being something that evaluates to a value. The <% means that
executable code follows. So in a page, you can do:
<%
String blah = "Hello world.";
%>
<p>Some HTML stuff</p>
<p>Here is your string: <%= blah %></p>
Or you can do:
<%
String blah = "Hello world.";
%>
<p>Some HTML stuff</p>
<p>Here is your string: <% out.println(blah); %></p>
The two will produce identical output. In your case, it would be
<%= testMethod("Test") %>
or
<% out.println(testMethod("Test")); %>
- Next message: JDany: "Re: Java and MySql program example ?"
- Previous message: Piotre Ugrumov: "Tutorial JAVA-XML"
- In reply to: Stuart Palmer: "Re: Newbie functions question"
- Next in thread: Herman Timmermans: "Re: Newbie functions question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]