hi, if i am writing the function in jsp progrom when i compile that it compiles to servlet and can u plz tell me where this function will be there either in init() or service() method. It is asked me in interview i said it will go in service method but that person said that can u write method inside the method.
Plz i am confuse.
Sukhbir
-
function in jsp (1 messages)
- Posted by: sukhbir bhavra
- Posted on: January 12 2003 11:48 EST
Threaded Messages (1)
- function in jsp by Oon Kean Lin on January 13 2003 01:11 EST
-
function in jsp[ Go to top ]
- Posted by: Oon Kean Lin
- Posted on: January 13 2003 01:11 EST
- in response to sukhbir bhavra
It will neither be init() nor service(). You can't have function within a function in Java. When you declare a function in JSP (via the <%! %> tag) , it will go inside the class of the compiled servlet.
e.g
<%@ page language="Java" %>
<%!
public void myMethod(String message) {
System.out.println(message);
}
%>
will result in something like this in the generated servlet :
public class test_jsp extends HttpJspBase {
public void myMethod(String message) {
System.out.println(message);
}
// Some other code ..
}