aspose file tools*
The moose likes Websphere and the fly likes how does this declaration differs !!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "how does this declaration differs !!! " Watch "how does this declaration differs !!! " New topic
Author

how does this declaration differs !!!

Manishada
Greenhorn

Joined: Feb 05, 2002
Posts: 5
<%!<br /> Connection conn = null %>
and
<% Connection conn = null %>.
Which one should be used....
mahadevan raja
Ranch Hand

Joined: Apr 11, 2001
Posts: 96
what was that??


SPECIALIST-WCSV5.1 Implementation.<br />SYSTEMS EXPERT-WAS4.0 Administration
Manishada
Greenhorn

Joined: Feb 05, 2002
Posts: 5
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
Andre Glauser
Greenhorn

Joined: Feb 12, 2002
Posts: 4
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
satya
Greenhorn

Joined: Jan 29, 2002
Posts: 16
Hi abhi... i mean manishada,
ur declaration is causing the single connection object to handle mutliple connectivity when the same jsp file is being accessed by concurrent users. this can lead to a prob when the close method is called as the other request won't get the connection and they will be forced to create new connections.
I hope things are clearer now. pl try the same and revert back.
regards,
satya
Manishada
Greenhorn

Joined: Feb 05, 2002
Posts: 5
Hi all,
Thanx for all those valuable suggestions.
Regards
By the way Mr.Satya what was that abhi i mean manishada !!! needs more clarification
satya
Greenhorn

Joined: Jan 29, 2002
Posts: 16
i don't why but instead of writing ur name i was going to write abhilash and then i stopped.. I hope things are clearer now. i hope u will not get a compilation error now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how does this declaration differs !!!