The first one is an incorrect JSP Declaration and the second one is an incorrect JSP scriptlet. Scriptlets are translated into the service method of the translated servlet, whereas the declaration is translated to the body of the servlet class.
The syntax in the example is incorrect they must both have a semi-colon at the end in order to compile. The declaration will become an instance variable whereas the scriptlet will become a method variable.
Therefore this
would get translated to something like this
So, depending on what you are going to do with the variable, will depend where you put it. But, preferably the option is to put your DB access code somewhere other than the JSP, i.e a JavaBean or EJB.
BTW: You should download and have a look at the JSP specification to see the JSP constructs.
------------------------------------
Originally posted by Manishada:
Sorry !! that was surprising !!
Actual doubt is:
This is how I declare my Connection Object
< ! Connection con=null %>
Is this is right ??
<% Connection con=null %>
Pls comment