Can we use main method inside JSP? Why?

Questions by ganeshvertech   answers by ganeshvertech

Showing Answers 1 - 15 of 15 Answers

rakesh

  • Nov 19th, 2007
 

No we can not use main method, because JSP required a web component and to run the JSP page need to deploy. It is to be consider when a JSP page is requested it is converted into servlet file then JVM inside server process that can provide us the page.

  Was this answer useful?  Yes

vishnu.baji

  • Feb 28th, 2008
 

I used main method in jsp it is working fine.... But don't know why it is behaving like that.... just tested and posting.... If anyone know plz post y it is working fine....

  Was this answer useful?  Yes

charankk

  • Apr 30th, 2008
 

here we are not writing any core application to start the jsp .
Basic concept is we can write any other method in jsp like servlet but no use.Who will call main method?.who will instantiate the object.

Do you think so its an valid question ?.

  Was this answer useful?  Yes

We can use main method in Jsp/servlet, but there is no use. This main() method will not execute throughout the life cycle. Then why should we need to use.

Generally these JSP/Servlets are server side technologies.These will be executed under webcontainer only. Webcontainer will execute JSP/servlet life cycle or callback methods only in order to execute JSP/Servlet.

So throughout the life cycle of JSP/Servlet, the webcontainer will execute init(ServletConfig),service(ServletRequest,ServletResponse),destroy() methods only.

Rgds,
Mulls

ashish

  • Aug 5th, 2011
 

Can someone tell me...how a servlet container execute init(),service() and destroy() method in a sequential manner ?
is it true that a servlet container itself contains a main() method which call these methods ?

thanks in advance...

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions