Hi everyone,
I am relatively new to JSP technology and going through some tutorials now.
For some reason when I try to access global JSP variables like
out,
session,
request or
response inside a method declaration as in the following code I get errors that they cannot be resolved. The code does not make a lot of sense but is supposed to run fine:
<%@ page import="java.util.*" %>
<HTML>
<BODY>
<%!
Date getDate()
{
out.println("inside getDate");
request.getRemoteHost();
return new Date();
}
%>
Hello! <br>
The time is now <%= getDate() %>
</BODY>
</HTML>
Server complains that it cannot resolve
out and
request although if I use these variables inside scriplets (and not inside method definitions) everything runs fine:
<%
out.println( date );
out.println( "<BR>Your machine's address is " );
out.println( request.getRemoteHost());
%>
What can be the reason for this? Any help is appreciated.
Thanks,
Anton.