how is a jsp page translated into servlet

Hi all, I have a small doubt in JSP. I want to know what are the stages during the conversion of a JSP page into its related servlet. Thanx in advance
[171 byte] By [Kishorea] at [2007-10-2 10:56:24]
# 1

When a user requests the JSP for first time the web container tries to convert it to Java file then the Java file is compiled to form class file then it loads the generated servlet class file.Then the container instantiates the servlet and causes the servlets jspInit() method to run then the objects are created which is ready to accept the objects ie the-jspService() method runs.

The JSP is converted to servlet only once in lifecycle abd after that it behaves as servlet throughout life cycle.

Innovaa at 2007-7-13 3:21:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Does the servlet container call the "jsp_init()" method or does it, when creating the translation unit, convert the "jsp_init()" method into the servlet "init(ServerletConfig config)' method?
tolmanka at 2007-7-13 3:21:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

The method name is jspInit() (not jsp_Init()), and it should be called by the particular JspPage implementation (extends Servlet) provided by the container. The JspPage implementation should over-ride the servlet's init() to, at least, call the jspInit() method at the very end.

The individual JSPs that get created by the container will extend the JspPage implementation.

As a general idea (and without any examples to look at now), this is what it may look like:

public abstract class MyContainersJspPageImpl implement HttpJspPage, JspPage, Servlet {

...

public static void init(ServletConfig) {

...

jspInit();

}

//default implementation. do nothing maybe? but let JSPs override me

//if they want to do some initialization at startup...

public static void jspInit() {

}

...

public void service(ServletRequest request, ServletResponse response) {

...

//somehow make HttpServletRequest/Response

_jspService(httpRequest, httpResponse);

...

}

public abstract void _jspService(HttpServletRequest request, HttpServletResponse response);

}

public class MyRealJSPMadeFromDotJSPFile extends MyContainersJspPageImpl {

public void jspInit() { // whatever you do in the jspInit

}

public void _jspService(HttpServletRequest request, HttpServletResponse) {

// do stuff to prepare implicit objects and do error handling

...

//do what you do in JSP

...

//clean up

}

...

}

stevejlukea at 2007-7-13 3:21:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
thanx stevejlukei got a very good example of what exactly the thing is happening am very thank ful to you
Kishorea at 2007-7-13 3:21:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...