i think i know what the problem is
you are creating a function and trying to use "session" and "response"
variables over there
this will not work. These variables are local to the service function of jsp
thats the entry point
And more over I am not very sure if u can create your own functions
And if you cant and u still need to use functions - try making the jsp
extend a class which has these functions
if u try using the session and response without functions it should work
(if it doesnt work and i have got u all confused send me a seperate mail
:-))
-----Original Message-----
From: Peter Bishop [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 12, 2001 3:28 PM
To: [EMAIL PROTECTED]
Subject: response & session access from Declarations
Hi,
Please excuse the naiveté of my question as I am knew to JSP/servlets.
Is it possible to refer to the session & response objects from inside <%!
declaration %> statements? As such:
<%!
public void CheckPassword(String strPass) {
if (strPass.length() < 1 ) {
session.setAttribute("ErrorMessage",
"The password field is empty");
response.sendRedirect("error_message.jsp");
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Check personal details</title>
</head>
<body>
<%
CheckPassword((String)request.getParameter("password1"));
%>
</body>
</html>
I keep receiving the following errors:
Undefined variable or class name: session
session.setAttribute("ErrorMessage", "The password field is
empty");
Undefined variable or class name: response
response.sendRedirect("error_message.jsp");
Thanks in advance.
Regards,
Pete
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
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
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
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