File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Dumb question - variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Dumb question - variables" Watch "Dumb question - variables" New topic

Dumb question - variables

Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 567
Being a thick-skulled greenhorn, I'm trying to get my head around the java in the JSP tags and I can't figure out how to use global variables or functions.
How can I declare a function in jsp java so that I can pass the parameters as reference parameters, not just copies? If it's anything like javascript, I can't, right?
How can I declare a global variable so that I can reference the variable inside functions and just in the script blocks?

I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
For "global" variables and methods in JSP for use in a single application - you might declare a bean with application scope.
See the JSP API documentation downloadable from

author of:
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 567
ok, i see i am going to have commit some time to learning the servlet/bean techniques, but what really flummoxes me now is why some of my "global" variables work - e.g. i've got my database access in a function and it sets the result set object in a global variable, but it can't set the error/warning messages variable, although they're both declared in the same place.
I agree. Here's the link:
subject: Dumb question - variables
jQuery in Action, 3rd edition