Variable scope problem... I think...

I am new to javascript writing and need a bit of help. I am writing a .jsp web page.
I have a javascript function which is:
var fso;
var e;
var theFiles = new Array();
int fileCounter = 0;
var TristateFalse = 0;
var ForWriting = 2;
var ForReading = 1;
myActiveXObject = new ActiveXObject("Scripting.FileSystemObject");
dataFile = myActiveXObject.GetFile("distPath.dat");
text2 = dataFile.OpenAsTextStream(ForReading, TristateFalse);
filepath = text2.ReadLine( );
text2.Close( );
function findFiles() {
fso = new ActiveXObject("Scripting.FileSystemObject");
e = new Enumerator(fso.GetFolder(filepath).files);
for (e.moveFirst(); ! e.atEnd(); e.moveNext()) {
theFiles[fileCounter] = e.item();
fileCounter++;
I call the function via onload in the <body onload="findFiles();">
the function works, as I have validated that by adding document.writeln(theFiles[fileCounter]) in the above function and get the output I expect (all the files in the directory pointed to by the distPath.dat file.
my problem is I want to display the
theFiles[fileCounter] array data better so I coded a table as below:
<table border="0" cellspacing="1" cellpadding="2" align="center" width="100%">
<tr align="center" bgcolor="#EEEEEE" valign="top">
<td> Filename </td>
</tr>
<% for (int i=0;i< fileCounter ;i++) { %>
<tr align="center" bgcolor="#FFFFFF">
<td> <%= theFiles %></td>
</tr>
<% } %>
</table>
when loading the page I get these errors:
An error occurred at line: 128 in the jsp file: /passwordAdminViewValidUserIDlist.jsp
Generated servlet error:
fileCounter cannot be resolved
(line 128 is the <% for (int i=0;i< fileCounter ;i++) { %> line)
An error occurred at line: 130 in the jsp file: /passwordAdminViewValidUserIDlist.jsp
Generated servlet error:
theFiles cannot be resolved
(line 130 is the <td> <%= theFiles %></td>
line)
can any one help?
Thanks,
K

This is a serious mix between JSP -> Java Server Pages; and JavaScript. Java is not JavaScript. The JSP scriptlets (inside the <% %> tags) runs on the server, before the client (browser) sees the code. JavaScript runs on the client, after the JSP is done and over with.
What does this mean? When your JSP is run, the JavaScript variables do not exist. JSP can't use them. When JavaScript runs, the JSP is done, so it can't be used to display the JavaScript variables.
You will have to decide what you want to use, either Java or JavaScript. Note, in Java (JSP) you will not be able to access the .dat file if it lives on the client's machine. I don't know activeX, so I don't know if that is what you are doing in JavaScript or not...

Similar Messages

  • Variable scope problem?

    I am not quite sure if this is a scope problem at all, but it looks like one....
    Here is the problem:
    I have a class in which I define a variable x as folowing:
    public class XX
    public var x:Integer;
    In my fx script file I give it a value:
    var t: XX {
    x: 10
    and it seems that it is initialized... however when I try to use the variable inside the class XX, it cannot be done.
    for example I what try to do is
    public var yy = YY {
    for (i in [1..x]){
    ...do something...
    and the cycle is executed only once!
    Is this due to my inexperience in javafx or it is a standard behavior?

    Is this due to my inexperience in javafx or it is a standard behavior? Both? :-)
    The classical way to compute a class variable from those initialized at construction time is to do that in an init (or postinit) block.
    It isn't really a problem of scope, rather of order of initialization.

  • Having Truble Reading and Echoing Using PHP in HTML. Possible Variable Scope Problem?

    Hey guys,
       Thanks for your always knowledgable help! Today I am working with displaying text from a text file in an HTML table using PHP. I can't get the data to display properly, I think it has something to do with the scope of the variables, but I am not sure. Here is the code I am struggeling with:
    <table width="357" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td width="165">Pizza 1</td>
        <td width="186"><? echo  $price['0']; ?></td>
      </tr>
      <tr>
        <td>Burger 1</td>
        <td><? echo $price['1']; ?></td>
      </tr>
      <tr>
        <td>Drink 1</td>
        <td><? echo $price['2']; ?></td>
      </tr>
    </table>
    In the above PHP (not shown) the array $price is filled properly (I tested by echoing each bit line by line) but by the time we get into the HTML it seems the array is empty or it is not liking how I am calling it. Does the scope of a PHP variable end with the closing "?>" tag? Am I missing something? Bellow is the full code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    body {
        background-color: #333;
        color: #FFF;
    </style>
    </head>
    <body>
    <?php
    $menu=fopen("prices.txt","r") or exit("Unable to open file!");
    $price=array();
    $priceposition=null;
    $tempstring;
    //This loop does all of the READING and populating of variables
    while(!feof($menu))
        //Check to see if this is the first pass, if not add one to the array possition
        if ($priceposition==null){
            $priceposition=0;
        else{
        $priceposition++;
        //populate the temparary string
        $tempstring = fgets($menu);
        //Populate the array if the temporary string is not a comment
        if(substr($tempstring,0,2) != "//"){
            $price['$priceposition']= $tempstring;
            echo $price['$priceposition'];
      //End of reading loop
    fclose($menu);
    ?>
    <table width="357" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td width="165">Pizza 1</td>
        <td width="186"><? echo  $price['0']; ?></td>
      </tr>
      <tr>
        <td>Burger 1</td>
        <td><? echo $price['1']; ?></td>
      </tr>
      <tr>
        <td>Drink 1</td>
        <td><? echo $price['2']; ?></td>
      </tr>
    </table>
    </body>
    </html>
    and you can run the code on my test server here: christianstest.info/phptest/readwritetesting/readtest.php
    thanks guys!

    MurraySummers wrote:
    Try changing this -
    fclose($menu);
    to this -
    fclose($menu);
    echo "<pre>";exit(print_r($price));
    and see what you get.
    Wow, what a great little peice of testing code, thanks! That showed me the problem right away! Is there any way to test your php line by line in Dreamweaver CS6? I am used to computer programing in Visual Studio and Eclipse where they have an option of running code line by line and seing how variables populate and change with each line of code execution. Or is thier a program that can do this for PHP?

  • Scop problem

    Hi ,
    I having a problem communicating with loaded swf inside main
    file.
    Im using that script to have a transition between external
    swf :
    http://www.kirupa.com/developer/mx2004/transitions.htm
    most of it working fine but im having problem communicating
    with variable:
    Stage.swf:
    The main movie start to play and on its last frame it has the
    following action:
    this._lockroot=true
    //loading the first movie after the animation finish
    _root.currMovie = "main";
    _root.MC_Container.loadMovie(_root.currMovie+".swf");
    stop();
    portfolio.swf
    Than I press on the portfolio button and I get another main
    portfolio swf that has external files loeaded as well.its dividing
    the portfolio into categories , each category loading external
    file.
    First frame:
    this._lockroot=true
    _root.currMovie = "portfolio_3d";
    _root.MC_Container.loadMovie("portfolio_3d.swf");
    midframe=10;
    stop();
    buttons :
    on (release) {
    if (_root.currMovie == undefined) {
    _root.currMovie = "portfolio_print";
    _root.MC_Container.loadMovie("portfolio_print.swf");
    } else if (_root.currMovie != "portfolio_print") {
    if (_root.MC_Container._currentframe >=
    _root.MC_Container.midframe) {
    _level.currMovie = "portfolio_print";
    _root.MC_Container.play();
    portfolio_3d.swf
    the external file that loaded into the portfolio file is for
    example : portfolio_3d.swf ,
    the first frame action:
    this._lockroot=true
    midframe=10;
    middle frame has a stop(); command
    the last frame loading the next after the current movie
    finish:
    _root.MC_Container.loadMovie(_root.currMovie+".swf")
    the problem is that in the portfolio page, when I click the
    sub categries(3d,print,etc) , I get always the same movie. It seems
    like the variable doesn’t see the movie in the lowest level.
    It seems like a scop problem
    my url :
    www.shaygaghe.co.il
    thanks for your time ,
    Shay Gaghe

    what is the script that you have on the buttons on the bottom
    of the page that are supposed to load the new content? I think it
    may have something to do with your lockroot.

  • CF9 struct key and variable name problem

    Running CF 9 on Linux, the following produces unusual results:
    <cfscript>
        a = { '99' = "that", '8X' = "this"};
        writedump(a);
    </cfscript>
    The dump shows only the keypair with the key '99' and the value 'this'. #a['99']# produces "this". #a['8X']# produces "this" as well. It's as though CF cannot distinguish between the tokens '99' and '8X'. Note that implicit assignment is not implicated:
    <cfscript>
        blah['GNQ'] = 'bad struct';
        blah['H02'] = 'worse struct';
    </cfscript>
    This yields a struct with one member per structcount(), with a key-value pair of GNQ='worse struct', but the key 'H02' accesses the same value. structkeyexists(blah, 'H02') returns true.
    On our systems (we've tried CF 9 on separate RH 4 and RH5 machines) the problem is not limited to structs per se, and seems to persist even when other characters are involved in variable or struct key names:
    <cfscript>
        testb0 = "test";
        testao = "test2";
    </cfscript>
    This produces an error page with the message "can't load a null". However, the following is possible:
    <cfscript>
        testb0 = "test";
        writeoutput("b0 = #testb0#<br/>");
        writeoutput("ao = #variables['testao']#<br/>");
        writeoutput("#structkeyexists(variables, "testao")#");
    </cfscript>
    The above produces the output 'test' for the undeclared variable 'testao', and also thinks that variables.testao is in the variables scope, even though it hasn't been declared.
    A quick loop or two and we've found that our CF 9 installations cannot distinguish between 340 two letter sequences, in matched pairs, as in the following example:
    ao = B0
    ap = B1
    aq = B2
    ar = B3
    as = B4
    at = B5
    au = B6
    av = B7
    aw = B8
    ax = B9
    Case does not seem to matter, and as mentioned above, this 'blindness' appears to persist even when the strings are embedded in other strings. E.g., when used as key or variable names, the following are being treated by CF as equal:
    slap = slb1
    tape = tb1e
    apes = b1es
    Has anyone else experienced anything like this? Could there be some strange setting that is causing CF to interpret the templates using some otherworldy codepage in which these characters are equivalent? Could there be something wrong with our installation, and/or our OS?
    Any hints, confirmation of our findings, and/or refutation of same would be greatly appreciated - we were hoping to move to CF 9 from CF 8 this week, but this is quite a showstopper for us.

    I did restart but turns out I fed the updater the zip file (hf900-81860.zip) instead of the jar file (hf900-81860.jar).  Now it returns the correct results, "abc" (not "123").  I also confirmed that this problem was not fixed by "Cumulative Hot Fix 1 for Coldfusion 9".  And, I verified that it fixed the more widespread issue in my application.  Thank you guys!
    HotFix (thanks buglug):
    http://kb2.adobe.com/cps/825/cpsid_82547.html
    Related bugIDs:
    81860
    81884
    82491
    Related posts:
    http://stackoverflow.com/questions/2164472/bug-in-cf9-values-for-unique-struct-keys-refere nced-and-overwritten-by-other-key

  • Javascript discussion: Variable scopes and functions

    Hi,
    I'm wondering how people proceed regarding variable scope, and calling
    functions and things. For instance, it's finally sunk in that almost
    always a variable should be declared with var to keep it local.
    But along similar lines, how should one deal with functions? That is,
    should every function be completely self contained -- i.e. must any
    variables outside the scope of the function be passed to the function,
    and the function may not alter any variables but those that are local to
    it? Or is that not necessary to be so strict?
    Functions also seem to be limited in that they can only return a single
    variable. But what if I want to create a function that alters a bunch of
    variables?
    So I guess that's two questions:
    (1) Should all functions be self-contained?
    (2) What if the function needs to return a whole bunch of variables?
    Thanks,
    Ariel

    Ariel:
    (Incidentally, I couldn't find any way of  marking answers correct when I visited the web forums a few days ago, so I gave up.)
    It's there...as long as you're logged in at least, and are the poster of the thread.
    What I want is to write code that I can easily come back to a few months later
    and make changes/add features -- so it's only me that sees the code, but
    after long intervals it can almost be as though someone else has written
    it! So I was wondering if I would be doing myself a favour by being more
    strict about make functions independent etc. Also, I was noticing that
    in the sample scripts that accompany InDesign (written by Olav Kvern?)
    the functions seem always to require all variables to be passed to it.
    Where it is not impractical to do so, you should make functions independent and reusable. But there are plenty of cases where it is impractical, or at least very annoying to do so.
    The sample scripts for InDesign are written to be in parallel between three different languages, and have a certain lowest-common-denominator effect. They also make use of some practices I would consider Not Very Good. I would not recommend them as an example for how to learn to write a large Javascript project.
    I'm not 100% sure what you mean by persistent session. Most of my
    scripts are run once and then quit. However, some do create a modeless
    dialog (ie where you can interface with the UI while running it), which
    is the only time I need to use #targetengine.
    Any script that specifies a #targetengine other than "main" is in a persistent session. It means that variables (and functions) will persist from script invokation to invokation. If you have two scripts that run in #targetengine session, for instance, because of their user interfaces, they can have conficting global variables. (Some people will suggest you should give each script its own #targetengine. I am not convinced this is a good idea, but my reasons against it are mostly speculation about performance and memory issues, which are things I will later tell you to not worry about.)
    But I think you've answered one of my questions when you say that the
    thing to avoid is the "v1" scope. Although I don't really see what the
    problem is in the context of InDesign scripting (unless someone else is
    going to using your script as function in one of theirs). Probably in
    Web design it's more of an issue, because a web page could be running
    several scripts at the same time?
    It's more of an issue in web browsers, certainly (which I have ~no experience writing complex Javascript for, by the way), but it matters in ID, too. See above. It also complicates code reuse across projects.
    Regarding functions altering variables: for example, I have a catalog
    script. myMasterPage is a variable that keeps track of which masterpage
    is being used. A function addPage() will add a page, but will need to
    update myMasterPage because many other functions in the script refer to
    that. However, addPage() also needs to update the total page count
    variable, the database-line-number-index-variable and several others,
    which are all used in most other functions. It seems laborious and
    unnecessary to pass them all to each function, then have the function
    alter them and return an array that would then need to be deciphered and
    applied back to the main variables. So in such a case I let the function
    alter these "global" (though not v1) variables. You're saying that's okay.
    Yes, that is OK. It's not a good idea to call that scope "global," though, since you'll promote confusion. You could call it...outer function scope, maybe? Not sure; that assumes addPage() is nested within some other function whose scope is containing myMasterPage.
    It is definitely true that you should not individually pass them to the function and return them as an array and reassign them to the outer function's variables.
    I think it is OK for addPage() to change them, yes.
    Another approach would be something like:
    (function() {
      var MPstate = {
        totalPages: 0,
        dbline: -1
      function addPage(state) {
        state.totalPages++;
        state.dbline=0;
        return state;
      MPstate = addPage(MPstate);
    I don't think this is a particularly good approach, though. It is clunky and also doesn't permit an easy way for addPage() to return success or failure.
    Of course it could instead do something like:
        return { success: true, state: state };
      var returnVal = addPage(MPstate);
      if (returnVal.success) { MPstate = returnVal.state; }
    but that's not very comforting either. Letting addPage() access it's parent functions variables works much much better, as you surmised.
    However, the down-side is that intuitively I feel this makes the script
    more "messy" -- less legible and professional. (On the other hand, I
    recall reading that passing a lot of variables to functions comes with a
    performance penalty.)
    I think that as long as you sufficiently clearly comment your code it is fine.
    Remember this sort of thing is part-and-parcel for a language that has classes and method functions inside those classes (e.g. Java, Python, ActionScript3, C++, etc.). It's totally reasonable for a class to define a bunch of variables that are scoped to that class and then implement a bunch of methods to modify those class variables. You should not sweat it.
    Passing lots of variables to functions does not incur any meaningful performance penalty at the level you should be worrying about. Premature optimization is almost always a bad idea. On the other hand, you should avoid doing so for a different reason -- it is hard to read and confusing to remember when the number of arguments to something is more than three or so. For instance, compare:
    addPage("iv", 3, "The rain in spain", 4, loremIpsumText);
    addPage({ name: "iv", insertAfter: 3, headingText: "The rain in spain",
      numberColumns: 4, bodyText: loremIpsumText});
    The latter is more verbose, but immensely more readable. And the order of parameters no longer matters.
    You should, in general, use Objects in this way when the number of parameters exceeds about three.
    I knew a function could return an array. I'll have to read up on it
    returing an object. (I mean, I guess I intuitively knew that too -- I'm
    sure I've had functions return textFrames or what-have-you),
    Remember that in Javascript, when we say Object we mean something like an associative array or dictionary in other languages. An arbitrary set of name/value pairs. This is confusing because it also means other kinds of objects, like DOM objects (textFrames, etc.), which are technically Javascript Objects too, because everything inherits from Object.prototype. But...that's not what I mean.
    So yes, read up on Objects. They are incredibly handy.

  • Function scope problem

    Hi all,
    I am using a class-based system for all my actionscript, but
    am having trouble getting the following code to work properly, and
    I am pretty certain it is a scope issue.
    public function
    setNavButtons(prevStart:Number,prevEnd:Number,nextStart:Number,nextEnd:Number){
    var owner = this;
    if (prevStart != undefined){
    mcPropertiesNav.btnBack.onRelease = function():Void{
    owner.reloadView(prevStart,prevEnd);
    if (nextStart != undefined){
    mcPropertiesNav.btnNext.onRelease = function():Void{
    owner.reloadView(nextStart,NextEnd);
    I've traced it out and know that when I use the reloadView
    method, the prevStart and prevEnd parameters are being passed in as
    undefined. Does anyone know how I would reference these variables
    within the onRelease functions?
    Thanks in advance
    Robert

    In the code you are posting a scope problem can't be
    pinpointed. The arguments you are providing are local to the
    function so there is no problem there. We might be able to help if
    you post the complete class.

  • Variable Scope Help Needed

    Can someone help me understand or can someone point me to the documentation that describes variables?
    I am thinking that variables defined in the BPELProcess are like global variables, variables defined in a scope are local variables to the scope, is this accurate?
    I am trying to access the receive activity input variable in my catch block but it appears to be empty, when a fault occurs do the "global" variables go out out of scope?

    Hi ,
    As soon as you create a BPEL process , you have a parent scope already .If you create variables for that scope then the variables are global and can be used any where in the complete process .
    Now , if you drag and drop some scope in it and if you creaete variables for that scope then it would become local to that scope ie.. it can be used only in that scope ie like local variables in called function in java.
    When you have an exception and when you try to catch the exception in the Catch block , you need to throw the catch variable and if you are using catch all block ,then there is no need for throwing but in both the cases you need to set the fault variable.Fault variable with the corresponding message has to be created earlier before assigning any values to it .
    Ideally Fault variables are kept global because some times you may require to propogate your fault to your parent scope ,it depends on your need .

  • Cfm template updating cfc variable scope

    Don't know if anybody's run into this before, but I ran into a strange issue with the variable scope in a cfc.  Basically, I have some application settings stored in a database table, and then I have a cfc saved to application scope in which I store the contents of the table in a variable scope query.  Within the cfc, I have a getter function that preforms a query of queries to pull the data I need.  I then have an admin screen within the application to update the settings.
    This is (very generally) what my cfc looks like:
    <cfcomponent  name="settings.cfc">
         <cffunction name="init" returntype="settings">  
              <cfset setAppSettings() />  
              <cfreturn this />  
         </cffunction>  
         <cffunction name="setAppSettings">  
              <cfquery name="variables.qrySettings" datasource="#application.dsn#">  
                   SELECT *
                   FROM SETTINGS
              </cfquery>  
         </cffunction>  
         <cffunction name="getAppSettings" returntype="query">  
              <cfargument name="id" />
              <cfset var local = structNew() />  
              <cfquery name="local.qryResult" dbtype="query">  
                   SELECT *
                   FROM variables.qrySettings
                   WHERE ID = <cfqueryparam value="#arguments.id#" cfsqltype="cf_sql_numeric" />  
              </cfquery>  
              <cfreturn local.qryResult />  
         </cffunction>  
    </cfcomponent>
    In onApplicationStart in Application.cfc, I have this line:
    <cfset  
    application.objSettings = createObject("component","settings").init() />

    Sorry, accidentally posted before I was done...
    Basically, the problem is that I have an admin screen that updates the settings.  I call the getter function in a cfm template, and I save the result to a variable called variables.qrySettings (same name as in the cfc) like this - <cfset variables.qrySettings = application.objSettings.getAppSettings(url.id) />.  For some reason, this seems to overwrite variables.qrySettings in the cfc.  Any ideas????

  • Variable Scope at package or interface level

    Hi,
    Can we set the ODI Project variable scope to package or interface level
    because in my project im using a last rundate refresh variable this variable value will be changed at the time of execution of each package.
    Thanxs
    Madhavi

    you can create it as "Not Persistent" and then its value exist per ODI session.
    In this way, several sessions can keep independent value to the same variable.

  • I have a problem with iPhone is that I can replace it at points of sale in the U.S. because I bought from Saudi Arabia because the problem I think in the hard ware software worked more than 3 times did not fix

    dears,
    I have a problem with iPhone is that I can replace it at points of sale in the U.S. because I bought from Saudi Arabia because the problem I think in the hard ware I do resoftware more than 3 times did not fix.
    Network also always missing.
    I am living in KS Wichita. I hope you help me pleas.
    Regards.

    iPhone warranty is not international. You will have to return your
    iPhone to Saudi Arabia for repair/replacement. Either take it back
    yourself or send to friend/relative for them to take to Apple. Apple
    will not accept international shipments for repair nor will Apple
    ship repaired/replaced iPhones out of the country where the repair
    was done.

  • I have a question my iphone4s has a problem when updated iOS8 there will be freeze problem i think iOS8 is not supported in 4s!!!!!!!!!

    i have a question my iphone4s has a problem when updated iOS8 there will be freeze problem i think iOS8 is not supported in 4s!!!!!!!!!.
    one more question when i phone5 update with iOS 8.1.2 this iOS supported iphone5???

    Hi Ios 8.1.2 Should work on iPhone 4s / 5 You may have a bug Backup to  cloud over WiFi Then Restore back to Factory  Settings This will make iPhone as new. Use same Apple ID & you will get your Apps & Data back Do Restore over your WiFi. Cheers Brian

  • I am having the same problem I think.  With mobileme you simply copy documents to the idisk folder and then synch.  I cannot seem to sink that folder anymore.  Any idea as to how I can simply copy folders to icloud and then access the MS Word and PDF file

    I am having the same problem I think.  With mobileme you simply copy documents to the idisk folder and then synch.  I cannot seem to sink that folder anymore.  Any idea as to how I can simply copy folders to icloud and then access the MS Word and PDF files on my iphone?

    Apple never bopthered to explain that this would happen
    Your iDisk is still accessible after moving to iCloud in exactly the same way as before. Nothing is deleted until June 30th 2012.
    , so I could easily have lost ALL of the files I kept on iDisk.
    No, you couldn't. Firstly, nothing was deleted from your iDisk. Secondly, any files stored on your iDisk should never be your only copy. Even if your iDisk spontaneously combusted, you should keep local backups elsewhere.
    Does Apple WANT people to move their storage elsewhere and stop paying Apple for it?
    Yes. Apple doesn't provide such a service anymore, nor are you paying them for it.
    Apple has made no effort to suggest remedies for the problem it has given iDisk users
    They've provided instructions on how to download your files from your iDisk. What you do with them after that is your choice.

  • Scope problem

    here is the function:
    public void readVector(File file)
    AddressBook addressBook = new AddressBook();
    try
    String string, token1 ="", token2 ="", token3 ="", token4 ="",
    token5 ="", token6 ="";
    FileInputStream fis1 = new FileInputStream(file);
    BufferedReader in = new BufferedReader(new FileReader(file));
    StringTokenizer st;
    while((string = in.readLine()) != null )
    st = new StringTokenizer(string);
    token1 = (st.hasMoreTokens())?st.nextToken():"";
    token2 = (st.hasMoreTokens())?st.nextToken():"";
    token3 = (st.hasMoreTokens())?st.nextToken():"";
    token4 = (st.hasMoreTokens())?st.nextToken():"";
    token5 = (st.hasMoreTokens())?st.nextToken():"";
    token6 = (st.hasMoreTokens())?st.nextToken():"";
    Contact c = new Contact(token1, token2, token3, token4, token5, token6);
    addressBook.addContact(c);
    catch(Exception ex)//catch exception and print stacktrace if try fails
    ex.printStackTrace();
    problem- some how I need to return the addresBook to another class, I can't do this because of a scope problem. Also if a solution is possible how would I call teh function in my other class.
    if this function returns an addressbook
    the prototype would be:
    AddressBook readVector(File file);
    how would I call this functino from another class to obtain the addressbok.

    I dont know what you mean by scope problem. Maybe you wanna elaborate on that a bit more. However, returning AddressBook should be straightforward. You can actually do it in two slightly different ways.
    1. You can define your readVector() method to be static:
    public static AddressBook readVector(whatever arguments) {
    ....your code here...
    Assuming you defined this method in class "foo", you can call this method using foo.readVector(arguments). In your calling function, you will probably have something like:
    AddressBook addressbk = foo.readVector(arguments);
    2. If you dont want to make your readVector() static, you will have to instantiate the class which contains this method. Again assuming class "foo" contains a definition like:
    public AddressBook readVector(args) {
    ....your code...
    In your calling method you will do the following:
    foo foo_obj = new foo();
    AddressBook addrbk = foo_obj.readVector(arguments);
    Of course, in either case your foo class has to be visible to the calling method. If your foo class is part of a different package, you will need to import it in the calling class.

  • How to identify the bind variable peeking problem?

    How to identify the bind variable peeking problem whether my db hitting or not and how to resolve it?
    currently we are doing the dbms_stat of application schema's with gather auto option and i hope this option we take the histogram stats also. Is there any option to improve it and its highly transactions oltp env of 11g.

    What is your exact 4 digits Oracle version ?
    Bind peeking issues are supposed to be solved with adaptative cursor sharing in 11.1 and 11.2:
    11.1 http://download.oracle.com/docs/cd/B28359_01/server.111/b28274/optimops.htm#sthref919.
    11.2 http://download.oracle.com/docs/cd/E11882_01/server.112/e16638/optimops.htm#PFGRF94588
    which says also:
    >
    Adaptive cursor sharing is enabled for the database by default and cannot be disabled. Note that adaptive cursor sharing does not apply to SQL statements containing more than 14 bind variables.
    >
    Edited by: P. Forstmann on 10 nov. 2011 13:50

Maybe you are looking for