| Author |
can we write main() in jsp
|
srinivas mallabathula
Greenhorn
Joined: Apr 12, 2011
Posts: 7
|
|
|
how can we write main() in JSP?then how it will execute?
|
 |
Dieter Quickfend
Ranch Hand
Joined: Aug 06, 2010
Posts: 280
|
|
Yes, but why in the world would you want to do this?
You can put a main method in a jsp just like you can put any other method. The purpose of it eludes me, however. Especially since scriptlets are bad practice.
A JSP is just a kind of servlet, you know. A servlet is a java class. You can put a main method in at will. There's just no point to it.
|
Oracle Certified Professional Java Programmer
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12327
|
|
You could not use a main() method for any kind of testing because a JSP depends on executing in the servlet container environment with a request and response , etc etc objects created by that environment.
Testing outside the servlet environment can be very helpful but you need to write classes that don't depend on the container.
Bill
|
Java Resources at www.wbrogden.com
|
 |
 |
|
|
subject: can we write main() in jsp
|
|
|