This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Dumb question - variables" Watch "Dumb question - variables" New topic
Author

Dumb question - variables

Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 566
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?
Thanks
Adam


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
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
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 java.sun.com
Bill

------------------
author of:
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 566
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Dumb question - variables