I think the problem might actually be that
the function needs to be put in <%! %> (declaration) tags instead of <% %>
(scriptlet) tags.
This is how I would change code:
<HTML>
<HEAD>
<%!
private String MyFunc2() { //This becomes method within the generated
jsp_Servlet
return "The value is returned from server side Function!";
}
%>
<%
String myStr;
myStr = MyFunc2();
%>
</HEAD>
<BODY> //added this to make a valid HTML page
<CENTER><B><H1>This Is the Second Page</H1></B></CENTER>
<FORM> //added this to make a valid FORM
<INPUT TYPE="text" SIZE=12 MAXLENGTH=10 NAME="MyText" VALUE="<%= myStr %>">
<--! You don't need this </SCRIPT> tag here -->
</FORM> //Added this to make a valid FORM
</BODY> //Added this to make a valid HTML page
</Html>
Hope this helps,
Abraham
-----Original Message-----
From: Susan Holden [SMTP:[EMAIL PROTECTED]]
Sent: Friday, October 08, 1999 8:09 AM
To: [EMAIL PROTECTED]
Subject: Re: Use ServerSide Functions In JSP
ZhangDong,
You need a semi colon after
<%function MyFunc2( )
It's in your first line after <HEAD>
sue
ZhangDong wrote:
> Hi all:
> I'm trying to use server side functions in JSP files.
> I have written a JSP page as following:
> <html>
> <HEAD>
> <%
> function MyFunc2()
> {
> return ("The value is returned from server side Function!");
> }
> String myStr;
> myStr = MyFunc2();
> %>
>
> </HEAD>
> <CENTER><B><H1>This Is the Second Page</H1></B></CENTER>
> <INPUT TYPE="text" SIZE=12 MAXLENGTH=10 NAME="MyText" VALUE="<%=myStr%>">
> </SCRIPT>
> </Html>
>
> But When I publishing this JSP file to my web server,I get the following error
>message:
> Error getting compiled page.
> C:\WEBSPH~1\APPSER~1\servlets\pagecompile\_MyPage2_xjsp.java:62: ';' expected.
> Function MyFunc2()
> ^
> 1 error
>
> Who can tell me the error?
> Thank advance!
> I'm using IIS4.0 + webSphere2.0
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> FAQs on JSP can be found at:
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html