Manipulation of LongRaw objects.

Hi all!
I have an application in which I am using OLE Container item
to embed employees photographs into the Oracle table. The field
is defined as a LONG RAW. I wanted to fetch the photograph of
the employee based on the employee number entered by the user.
One way is to make a base table form and use execute_query built
in. This works. But I require a control block and need to get
the Long Raw field into a variable and then assign it to the
forms bind variable. How to go about it??
Pl. treat this as URGENT..
Thanks..
Srini
null

Hi Matt,
So I have implemented a function that computes a new RenderTransformOrigin (RTO) for each object in a group. The new RTOs are computed around the center of the group of objects. Then transforms are applied in a loop and the objects will rotate as a group
around the common center. It's great!
However, if the object is scaled, then when the new RTO is applied, the object shifts. I have not been able to discover the mathematical relationship so I have not been able to compensate for this. Consider the following XAML:
<Grid Background="White">
<Canvas Width="772" Height="772" Background="#330000FF" RenderTransformOrigin="0.5,0.5">
<Rectangle Width="200" Height="200" Fill="Red" Canvas.Left="286" Canvas.Top="286" />
<Canvas.RenderTransform>
<CompositeTransform TranslateX="0" TranslateY="0" ScaleX="0.439999997615814" ScaleY="0.439999997615814" />
</Canvas.RenderTransform>
</Canvas>
</Grid>
If ScaleX and ScaleY are 1.0, then you can change the RTO to anything (0.5, 0.25 for example) and the canvas will remain where it is, ready for further transformations. However, if the scale values are not 1.0, then the object will shift whenever the new
RTO values are applied.
Can you shed some light on what is happening here?
Thank you,
Thaine Norris

Similar Messages

  • Manipulation event - repositioning object

    Hi,
    I am working on an app where I draw several objects. I detect a mouse click on one of them using ManipulationStarted, move the object using ManipulationDelta. It all works well, except that the selected object is not drawn on top of the other objects.
    So when it is moved across the screen, it can move underneath another object. Before I used the Manipulation event, I solved this by removing the object from the canvas and then redrawing it so that it would move over all other objects, on top of them. If
    I try this in ManipulationStarted, ManipulationDelta does not work.
    I am unable to find a way around this - assistance would be much appreciated.
    Thanks and regards,
    Lynn

    If it's on a canvas, you should increase it's z-index so it's on top of everything else.
    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.
    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined
    objects and unknown namespaces.

  • Inserting and manipulating data in object tables resulting from inheritance

    Dear All,
    Let's say we have the following definitions:
    create type t1 as object(x number) not final;
    create type t2 under t1(y number);
    create table t1t of t1;
    create table t2t of t2;
    If I want to insert a new row in t1t I can do insert into t1t values(t1(1));
    How would I deal with the case of t2? I tried
    insert into t2t
    select z(12, select value(e).x from t1t e where e.x=12))
    to no availability.
    How can I run an insert in t2t without replicating the information of the parent object of t1?
    Regards,
    Jim

    Hi Parmar18,
    Regarding your description, the rows are having same pattern with tabs(CHAR(9)) as delimiter in between dates and amounts, what is the delimiter between in a date and amount pair then? I suppose that is a space(CHAR(32)), you can reference the below sample
    to code to achieve your requirement.
    DECLARE @Str VARCHAR(MAX)
    DECLARE @T TABLE(ID INT, String VARCHAR(MAX))
    INSERT INTO @T VALUES(1,'immediate due 14,289.00 04/15/15 5,213.00 05/15/15 5,213.00 06/15/15 5,213.00 07/15/15 5,213.00 08/15/15 5,213.00 09/15/15 5,213.00 10/15/15 5,213.00 11/15/15 5,210.00')
    INSERT INTO @T VALUES(2,'04/15/15 5,213.00 05/15/15 5,213.00 06/15/15 5,213.00 immediate due 14,289.00 07/15/15 5,213.00 08/15/15 5,213.00 09/15/15 5,213.00 10/15/15 5,213.00 11/15/15 5,210.00')
    SELECT ID,
    SUBSTRING(StringLiteral,1,CHARINDEX(CHAR(32),StringLiteral)) AS DATE,
    RIGHT(StringLiteral,LEN(StringLiteral)-CHARINDEX(CHAR(32),StringLiteral)) AS AMOUNT
    FROM @T
    CROSS APPLY
    (SELECT REPLACE(StringLiteral,'immediate due',CONVERT(VARCHAR(8),GETDATE(),1)) StringLiteral FROM dbo.fnSplitDelimitedStringList(String,CHAR(9))) AS CAT
    The User-Defined Function fnSplitDelimitedStringList is referenced from
    here.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • Manipulating java array object in an oracle procedure

    hi there,
    i have a java store procedure that returns an array of filenames, and i have an oracle stored procedure that will for each filename returned in the java array object, open that file do some processing and load the data into database tables, now my question is, would an oracle 9i varray object be compatible with a java array, or should i pass in a pl/sql table to store the filnames returned?
    i really am stuck at this point and need help !!!!
    Thanx

    Wole,
    Have you searched the code samples available at the Technet Web site? Could you not find a relevant one?
    Have you tried searching the Ask Tom Web site?
    Good Luck,
    Avi.

  • Disable manipulation of OLE Objects in Previewer

    Hello to all,
    I've developed several reports containing OLE objects stored in tables. These maybe Word Docs, Excel Sheets, images, etc. The OLE objects are displayed in the previewer / printout correctly. But when you doubleclick on an OLE object in the Previewer the OLE server app starts and you can manipulate these objects. When you return to the Previewer these changes can be printed but are not stored in the database (which is alright). Now here is my problem : as these printouts represent electronically signed documents, no change in its contents is allowed. How can i prevent the user form changing these objects ?
    I hope I made my problem clear. Thanks to anyone who can help.
    Regards,
    Kai

    Hi,
    What is your Apex version?
    Is your Apex instance runtime environment or can you login to INTERNAL workspace?
    See this for Apex 4. Document do not say how disable demonstration app creation on runtime environment.
    http://download.oracle.com/docs/cd/E17556_01/doc/admin.40/e15521/adm_mg_service_set.htm#sthref255
    Regards,
    Jari

  • Manipulating 3d virtual objects as a control interface.

    The graphics used at ButtonRing.com need to be upgraded to a 3D java object of three skinnable concentric rings with a crystal ball in the center. Rotating the rings by cursor dragging should have configurable effects.
    Can anybody help with this?

    tst's suggestion for identifying the decoration with a tag is a good one.  I was going to suggest this, along with using the TRef Traverse for References.vi found in vi.lib\utility\traverseref.llb.  I'm pretty sure this LLB is present in LabVIEW 8.0 and later.  With this VI, you can simply traverse the front panel for items of the "Text" class, then iterate over the results to see which one matches the tag you set.  Traversing automatically looks inside nested objects, so you can avoid the task of having to go look "inside" the tab control.
    All that being said, if I were writing an app like this, I probably would have started off using a transparent string indicator. 
    Message Edited by Darren on 03-29-2009 10:42 AM
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • User is getting Error while opening a Discoverer report::Model Manipulation

    Hi,
    I am stuck with a peculaiar error as reported:
    While opening a Discoverer Report its giving Error:
    Model manipulation via state object.Server writes and pass through reads can only be made on objects attached to the model
    instance of
    oracle.disco.model.corbaserver.ScheduleRunWorkbookInfoImpl made state from:removed from
    oracle.disco.model.corbaserver.schedule.ScheduleRunWorkbookInfoImpl
    Kindly any help will be benefitial for me.
    Thanks and Regards

    Pl post details of OS, database and Discoverer versions. Pl detail the steps to replicate this error. This MOS Doc may be helpful
    734850.1- Error "Failed to Find Workbook ParameterValue.." When Trying to Edit Scheduled Discoverer Workbooks
    HTH
    Srini

  • How do I distort only part of an object?

    A newbie, still getting used to manipulating (esp distorting) objects. I haven't been able to figure out how to distort just a portion of an obect.
    I have an object (a compound shape) with many anchor points, an object made from a scanned ink drawing. It's a helmet with two intricate pieces that come down on either side. I need to make these hanging parts shorter while the rest of the object remains unchanged, so I want to basically select these parts of the object via the direct selection tool and resize them vertically, but all of the distortion tools I can find effect the entire object.
    I tried to separate these parts of the object, distort, then re-attach them to the main object, but then I loose the compound shape and all the "holes" on the inside of the object become filled and don't come back even when I re-compond the shape. Also, this seems like an impractical work around to a simple problem.
    What am I missing?
    thanks in advance

    Wade, as the OP said, intricate pieces, imagine more complex paths, like the straps of this helmet. Otherwise as you suggested, moving up  the bottom points of a shape like a rectangle with no other points between bottom and top, of course will work nicely
    I wish Illustrator had a feature similar to the smart content aware scaling in Photoshop where the user can mark the areas to scale and the areas to be preserved.

  • One pair of radio buttons to control multiple text objects - Designer 8.0

    Greetings - a big thank you in advance for any assistance. I have often found answers to my problems on this forum, but have been unable to find an answer to the following.
    The short of it - is it possible to make a pair of radio buttons control the visibility of multiple text objects with the same name(I have had success in manipulating only a single text object with one pair of buttons)?
    The long of it - I am trying to make a form bilingual based on the value of a radio button group to control the visibility of the text object in the selected language. When the user selects the language they wish to see, all the text objects in the form switch to that language. I am working with a dynamic PDF.
    I have succeeded to a very limited extent in manipulating one text object by overlaying text objects in both languages, setting one object to "invisible" as default, and controlling that text objects visibility with the following JavaScript in the click event of the radio button group:
    ----- form1.#subform[0].ENG_JPN::click: - (JavaScript, client) -------------------------------------
    if (ENG_JPN.rawValue == 1)///1 equals the value of on
    {English.presence = "visible";}
    else
    {English.presence = "invisible";}
    if (ENG_JPN.rawValue == 2)///2 equals the value of on
    {Japanese.presence = "visible";}
    else
    {Japanese.presence = "invisible";}
    endif
    The problem is I need to manipulate the visibility of all text objects with the same name on the form with a single radio button group. I have tried writing the code as one does for the sum of a repeating field, ie. English[*].presence etc. however I get a C++ error in preview.
    Any ideas are greatly appreciated. I am truly stumped - thank you for your time.

    To access objects with the same name you need to deal with occurance numbers. If your object is called TextField then the 1st occurance will be TextField[0], the second occurance will be TextField[1] etc.....
    The issue is that the [] in javascript are interpretted as an array element so you have to use the syntax: xfa.reolveNode("string") to get to your object names. In your case you would use:
    xfa.resolveNode("TextField[1]").presence = "visible"
    This string syntax allows you to use a var to hold the index number and is very useful with for loops where you want to set large numbers of objects. So if the index was held in the var i then your syntax would be:
    xfa.resolveNode("TextField[" + i + "]").presence = "visible"
    If the objects are in a repeating subform then the occurance numbers are on the subform and not the object. You can always get the expression to use by app.alert(objectname.somExpression). This will return the expression that you need to create.
    Make sense?

  • Copying Lookout Objects

    Is there any way to copy Lookout "Expression" and "Average" objects using
    the keyboard shortcuts (i.e. "CTL-C") or with the mouse?. I can
    successfully copy objects such as "Gauges" and "Pots" and Lookout creates a
    new object with a number appended to the end of the original name. If I try
    to do the same thing with the expression it just creates a linked copy of
    the same object. I have many expressions that are practically identical
    except for the name and the source and I have to do "Object >> Create..."
    every time! This is REALLY slowing down my development.
    Geoffrey B. Klotz
    GK Associates, Inc.
    TEL: (805) 523-8700
    FAX: (805) 523-1216
    EMAIL: [email protected]

    Thanks for the suggestions. Editing the .lks file seems to work great. I
    figured out that when you are finished editing the source that you have to
    recompile manually. Maybe on a future release of Lookout, NI can include a
    text editor for manipulating the source code similar to some of the HTML
    editors like MS FrontPage.
    One other suggestion is adding a feature to the "alignment" commands that
    will make all highlighted display boxes equal in dimension. The most time
    consuming part of creating a user panel right now is manually manipulating
    each gauge object with the mouse and trying to match the size of previously
    created display objects.
    All in all, a nice product. Thanks again.
    Geoffrey B. Klotz
    GK Associates, Inc.
    TEL: (805) 523-8700
    FAX: (805) 523-1216
    EMAIL: [email protected]
    Guy McDonnell wrote in message
    news:[email protected]..
    > One approach, though it can be perilous, is to manualy edit the .lks file
    > with a basic text editor that does not force hidden character such as eol.
    > This approach allows the copy paste option you reference. I usually use
    the
    > editor with my C compiler but notepad will also work.
    >
    >
    > "newsgroups.ni.com" wrote in message
    > news:[email protected]..
    > > Is there any way to copy Lookout "Expression" and "Average" objects
    using
    > > the keyboard shortcuts (i.e. "CTL-C") or with the mouse?. I can
    > > successfully copy objects such as "Gauges" and "Pots" and Lookout
    creates
    > a
    > > new object with a number appended to the end of the original name. If I
    > try
    > > to do the same thing with the expression it just creates a linked copy
    of
    > > the same object. I have many expressions that are practically identical
    > > except for the name and the source and I have to do "Object >>
    Create..."
    > > every time! This is REALLY slowing down my development.
    > >
    > > --
    > > Geoffrey B. Klotz
    > > GK Associates, Inc.
    > > TEL: (805) 523-8700
    > > FAX: (805) 523-1216
    > > EMAIL: [email protected]
    > >
    > >
    > >
    >
    >

  • Exception access violation using jlong instead of jint

    Hi,
    I hope you can help me.
    I'm using Java5 under Windows XP and I'm developing under Eclipse.
    I try to use an "old" c-Application accesed via JNI.
    Status Quo is that, I have access to the c-side, over my JNI-conform DLL. My current task is to translate the c-side structs to java-objects. This also works, but only with limitation.
    Calling methods bidirectional is working, manipulation a java-object is like a walk on an warm and sunny Saturday afternoon.
    But I'm not able to use all possible parameters (for now I have tried to use jobject, jstring, jint, jboolean, jlong).
    The first problem I had, were using Strings as parameters, but this now I deal with the loopway over java/lang/object (using java/lang/String results in an access_violation).
    The next problem, and the harder one, is, that I cannot use the type long or jlong.
    int (jint) is no problem, with int all works fine, but if I change the environment, creating and using long, I allways get an the access_violation shown below.
    Is there anything, I need to know?
    working c-side-code:
    jobject someObject;
    jint anIntegerValue;
    anIntegerValue =5;               
    jmethodID mid3 = (*env)->GetMethodID(env, cl, "initReturnSomeObject", "(ILjava/lang/Object;)Ljava/lang/Object;");
                   if(mid3 == (jmethodID)0) printf("\ndooofes MethodName4!\n");
                             else {
                                  const char* myParams;
                                  myParams = "ooooohwow!!!";
                                  someObject = (*env)->CallObjectMethod(env, jobj, mid3,
                                             anIntegerValue, (*env)->NewStringUTF(env, myParams));
                             }wokring java-side-code
    public Object initReturnSomeObject(int i, Object obj) {
              String s = (String)obj;
              System.out.println("String: "+s+"\nInteger: "+i);
              some = new SomeObject(s,i);
              if(some==null) System.out.println("Some is not yet initialized, FEAR!!!!\n");
              else System.out.println("Yoh, I'm soooo many good!! \nSome:\nString: "+some.getS1()+"\nInt: "+some.getI1()+"\n");
              return (Object)some;
    so, und this code, doesn't work. you can see, the changes are dramatically!! ;)
    sorry for my sarcasm. I do not know, why it doesn't work.
    jlong aLongValue;
    aLongValue = 2;
    jmethodID mid3 = (*env)->GetMethodID(env, cl, "initReturnSomeObject", "(JLjava/lang/Object;)Ljava/lang/Object;");
                   if(mid3 == (jmethodID)0) printf("\ndooofes MethodName4!\n");
                             else {
                                  const char* myParams;
                                     myParams = "ooooohwow!!!";
                                  someObject = (*env)->CallObjectMethod(env, jobj, mid3,
                                            aLongValue, (*env)->NewStringUTF(env, myParams));
         public Object initReturnSomeObject(long i, Object obj) {
              String s = (String)obj;
              System.out.println("String: "+s+"\nInteger: "+i+"\nLong: ");
              some = new SomeObject(s,(int)i);
              if(some==null) System.out.println("Some is not yet initialized, FEAR!!!!\n");
              else System.out.println("Yoh, I'm soooo many good!! \nSome:\nString: "+some.getS1()+"\nInt: "+some.getI1()+"\n");
              return (Object)some;
    # An unexpected error has been detected by Java Runtime Environment:
    #  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d942975, pid=1784, tid=1648
    # Java VM: Java HotSpot(TM) Client VM (1.6.0_03-b05 mixed mode, sharing)
    # Problematic frame:
    # V  [jvm.dll+0x182975]
    # An error report file with more information is saved as hs_err_pid1784.log
    # If you would like to submit a bug report, please visit:
    #   http://java.sun.com/webapps/bugreport/crash.jsp
    #do you need some other informations or details? something out of the log-file? ok, i have to take the bus, so sorry for uncomplete informations or sentences ;)
    till later.

    Hi,
    I'm quite sure, the signature is correct. For failure check, yesterday I ran javap to check the signature, but I do also mean, that I changed the signature afterwards for several time. And, it works ;) at least the way, using Integer.
    Trying to use java/lang/String everytime I got the Error, that the method could not be found - this is the part, I was wrong in my description. So the error-Message is a different one.
    Belonging to the question for assumptions I made... it's difficult. I'm quite new to JNI, so, I don't know, what I can assume to do. The Method call seems to be a kind of reflection-mechanism. So I assume that the behaviour is similar. But reflection I'm not very firm, either ^^.
    What I do assume is, that the parameter-value J fits to the java-type jlong. But a work around on this, I will try today. getting the jlong into an char* or using long instead of jlong or using Ljava/lang/Long; or a casted Long as Ljava/lang/Object; ...
    I'm anxious to the ideas, I will have, bypassing this point. if there is no way, I will write a file, send a email or something like this ;)
    Thx for thinking about my problem jschel!! It's great not to be alone.
    John

  • Best strategy for data definition handling while using OCCI

    Hi, subject says all.
    Assuming to use OCCI for data manipulation (e.g. object navigation), what's the best strategy to handle definitions in the same context ?
    I mean primarily dynamic creation of tables and columns.
    Apparent choices are:
    - SQL from OCCI.
    - use OCI in parallel.
    Did I miss anything ? Thanks for any suggestion.

    Agreeing with Kappy that your "secondary" backups should be made with a different app. You can use Disk Utility as he details, or a "cloning" app such as CarbonCopyCloner or SuperDuper that can update the clone periodically, rather than erasing and re-copying from scratch.
    [CarbonCopyCloner|http://www.bombich.com> is donationware; [SuperDuper|http://www.shirt-pocket.com/SuperDuper/SuperDuperDescription.html] has a free version, but you need the paid one (about $30) to do updates instead of full replacements, or scheduling.
    If you do decide to make duplicate TM backups, you can do that. Just tell TM when you want to change disks (thus it's a good idea to give them different names). But there's no reason to erase and do full backups; after the first full backup to each drive, Time Machine will back up only the changes made since the last backup +*to that disk.+* Each is completely independent.

  • My B+Tree can compile but have runtime error ... i can't tink why ...

    Sorry to bother anyone ... i have spent almost 3 weeks trying to debug the problem...
    My B+ Tree can compile but can't run as it throw invalid Null pointer Exception ..
    I suspected the error is in the split (int order ) method in the BTreeNode class but i can't remedy for it
    This my program code
    public class BTree {
    * The order of the B-Tree. All nodes of the B-Tree can store up to 2*order key values.
    private int order;
    * The number of key (with associated data values) stored in the B-Tree.
    private int count;
    * The root node of the B-Tree
    private BTreeNode root;
    * The first leaf node in the B-Tree. This field is used to give the starting point for sequential
    * access to the keys and data stored in the leaf nodes.
    private BTreeNode first;
    * The last leaf node in the B-Tree. This field is used to give the starting point for reverse
    * sequential access to the keys and data stored in the leaf nodes.
    private BTreeNode last;
    * A change count that can be used to invalidate iterators. This field is updated whenever a key plus data pair
    * is added to the B-Tree (or the data associated with a key is changed), or when a key plus data pair are
    * deleted from the B-Tree.
    private int changeCount = 0;
    // WHEN DOING ASSIGNMENT 5, DO NOT ADD ANY ADDITIONAL FIELDS TO THIS CLASS
    // You will loose marks if you add additional fields to this class. The fields above are all that
    // you need. If you need a variable in a method, use a local variable. I have seen too many
    // assignments where students add fields rather than create local variables. Hopefull the threat
    // of loosing (quite a few) marks will help reduce this habit.
    * A general exception class for errors when constructing or manipulating a B-Tree. Use the string
    * parameter to the constructor to say what the error really is.
    public class BTreeError extends RuntimeException {
    public BTreeError(String reason) {
    super(reason);
    * A constructor that creates an empty B-Tree of the given order.
    * <p/>This is the only constructor provided at the moment for this BTree class. Could consider
    * adding the equivalent of a 'copy constructor' that creates a new BTree object from an existing
    * BTree object.Constructor
    * creates the root of a btree
    * A constructor that creates an empty B-Tree of the given order.
    * <p/>This constructor need to copy the order parameter to the field of same name, and initialise the
    * root, cound, first and last fields of the BTree object.
    * @param order The order of the BTree.
    public BTree(int order) {
    count = 0;
    this.order = order;
    root = new BTreeNode(true, null, -1, null, null);
    first = root;
    last = root;
    * A method to return a SequentialIterator object that is positioned just before the first key
    * of the BTree object.
    * <p/>Do not modify this method.
    * @return A SequentialIterator object.
    public SequentialIterator iterator() {
    return new BTreeIterator();
    * A mehtod to return a SequentialIterator object that is positioned at a key found through a call
    * to the searchFor() method.
    * <p/>Do not modify this method.
    * @param position A SearchPosition() object that usually has been returne by a call to the searchFor() method.
    * @return A SequentialIterator object initialised to start at particular key in the BTree.
    public SequentialIterator iterator(SearchPosition position) {
    return new BTreeIterator(position);
    * A method to return a string representationo the BTree.
    * <p>The format of the string is:
    * <pre>BTree: Order=<digits>, size=<digits>, root=<BTreeNode string></pre>
    * <p/>Do not modify this method.
    * @return A string to represent the BTree
    public String toString() {
    StringBuffer s = new StringBuffer("BTree: Order=");
    s.append(order).append(", size=").append(size()).append(", root=").append(root.toString());
    return s.toString();
    * Method to determine the number of records stored in the B-Treee.
    * <p/>Do not modify this method
    * @return the number of records in the B-Tree.
    public int size() {
    return count;
    * method to return the order of the B-Tree.
    * <p/>
    * <p>This is the smallest number of key values for all nodes
    * except the root node. The maximum number of key values in a node is 2*order, and the maximum number
    * of child nodes for a node is 2*order+1.
    * <p/>Do not modify this method.
    * @return The order of the B-tree.
    public int order() {
    return order;
    * Insert a key plus data value into the BTree.
    * <p/>This method needs to locate the leaf node in which the key + data value should be
    * inserted, and then call the insertLeaf() method of BTreeNode to do the insertion.
    * <p/>This method will always result in a change to the BTree, so it should increment
    * the change count.
    * <p/>The method may result in only the data associated with an existing ke being changed,
    * so incrementing the count field should be done in the BTreeNode method (if needed).
    * <p/>This is one of the method you need to complete for assignment 5.
    * @param key The key associated with the data value to be added to the B-Tree
    * @param data The data value to be added (with it's associated key) to the B-Tree.
    public void add(Comparable key, Object data) {
    // you need to add the code for this method
    // i added
    BTreeNode btNode = root;
    while (!btNode.isLeaf) {
    int i=0;
    while(key.compareTo(btNode.keys) > 0) {
    i++;
    if (i == btNode.numberOfKeys) break;
    btNode = btNode.childNodes[i];
    btNode.insert(key,data);
    if (root.numberOfKeys == order*2-1) root.split(order);
    * insert a object with the given key into the tree
    //KeyNode keyNode = new KeyNode(key, data);
    // BTreeNode keyNode = new BTreeNode(key,data);
    BTreeNode btNode = root;
    while (!btNode.isLeaf) {
    int i=0;
    while(key.compareTo(btNode.key(i)) > 0) {
    i++;
    if (i == btNode.numberOfKeys())
    break;
    btNode = btNode.child(i); }
    System.out.println("hmm1");
    btNode.insert(key,data );
    System.out.println("hmm2");
    if (root.numberOfKeys == order*2-1)
    System.out.println("hmm3");
    root.split(order);
    System.out.println("hmm4");
    * This method searches the B-Tree for an occurence of the key in a leaf node and returns the result
    * of the search in a SearchPosition object.
    * <p/>Note that the key may occur in an interior node of the BTree without occuring in the leaf
    * nodes. This can be the result of a deletion operation. This method need to search down to the
    * leaf node that should contain the key if the key and associated data is in the B-Tree, and then
    * scan through the keys in the leaf node for the search key.
    * <p/>The result of the search is returned as a SearchPosition object, as this allow the return
    * of the success or failure of the search, as well as the data belonging to the key. It also
    * allows position information to be returned so that an interator can be initialised with the
    * key as the starting position for subsequent sequential access to adjacent keys.
    * <p/>This is one of the method you need to implement.
    * <p/>Implementation nodes:<br>
    * You need to find the leaf node that may contain the key (same code as for add()), then
    * scan the leaf BTreeNode for the search tree. You can do this within this method, as you
    * have total access to the fields and methods of BTreeNode (as BTreeNode is an inner class
    * of BTree). If you find the key, construct and return a SearchPosition object with the appropriate
    * details of the position, otherwise construct add return a SearchPosition object that indicates the
    * search failed.
    * @param key The key to search for in the BTree
    * @return A SearchPosition object returning the data and position information for the search
    public SearchPosition searchFor(Comparable key) {
    // You need to add the code for this method. The code below simply creates a
    // SearchPosition object which indicates an unsuccessful search.
    return new SearchPosition(false, null, -1);
    * A method to delete a node from the BTree.
    * <p/>The method should return the data object that was deleted when the key plus data object pair
    * are deleted from the B-tree.
    * <p/>The method should throw a BTreeError exception (with an appropriate reason string) if the
    * key is not found in the B-tree.
    * <p/>This is a method you can implement for bonus marks in Assignment 5.
    * <p/>Implementation notes:<br>
    * The easiest way to proceed is to use searchFor() to determine if they key is in the BTree, and
    * (if it is in the B-tree) to return position information about the key. Throw an exception if the
    * key is not in the B-tree, otherwise keep a copy of the data assocaited with the key (to return),
    * then for the leaf node containing the key (a BTreeNode object), call the deleteLeafNodeKey() method,
    * passing across the leaf key index of the key (so you don't have to find it again in the leaf node).
    * After this method deletes the key, return the data you saved as the method result.
    * @param key The key to delete (along with it's associated data) from the B-tree.
    * @return The data associated with the key that was deleted.
    public Object delete(Comparable key){
    // You need to add the code for this method.
    return null;
    * The inner class BTreeNode is used to represent the nodes in the B-Tree.
    * <p/>The nodes in the BTree are of two types:
    * <ol>
    * <li>Leaf nodes that contain the keys and associated data values, stored in ascending key order.<br>
    * These leaf nodes have next and previous pointers to adjacent leaf nodes to allow an easy
    * implementation of an iterator class to provide bi-directional sequential access to the keys stored
    * in the BTree nodes.
    * <li>Interior nodes that contain keys and links to child nodes (that are either all internal nodes
    * or all leaf nodes), organised as the node of a multi-way search tree. The interior nodes have
    * one more child node link than keys. The child node link at index k is to a node with keys that
    * are all less than the key at index k in this node. The link at index k+1 is to a child node
    * with keys that are all greater than or equal to the key at index k.
    * </ol>
    * The BTreeNode class allows you to create these two 'types' of nodes, depending on the parameters
    * passed to the constructor.
    * <p/>There are methods that should only be called for leaf nodes and methods that should only be
    * called for interior nodes. These methods should throw an exception if called by the wrong node
    * type. This class should really be designed using inheritance to mimic the pascal/C++ variant
    * record structure, but this design is relatively easy to understand and to implement.
    * <p/>Note that this class is an inner class of BTree, and so all objects will have an implict
    * reference to the BTree container object. This class has direct access to all the fields of the
    * BTree contaner object. In particular, the order of the BTree is available, hence this class
    * does not need to keep a copy of the order as a field.
    * <p/>Skeleton class provided for Objects and Algorithms Assignment 5
    * <p/>Only modify the methods where the JavaDoc indicates that you need to provide code.
    * @author a.sobey
    * @version 1.0
    * Date: 16/05/2005
    public class BTreeNode {
    * The actual number of key values stored in the BTreeNode. <br>Note that the BTree node has an implicit
    * reference to the containing BTree object, and the maximum number of nodes that can be stored in a
    * a BTreeNode (except temporarily during the split operation) is twice the <i>order</i> of the BTree.<br>
    * This field is valid for both internal and leaf nodes.
    private int numberOfKeys = 0;
    * The array of pointers to child nodes of this node. Only <i>(numberOfKeys+1)</i> are valid if <i>numberOfKeys</i>
    * is non-zero.<br>
    * This array is only valid and created for internal nodes - this array is not created for leaf nodes.<br>
    * There is space in the array created for one additional child node link - this makes the coding for
    * splitting of an internal node easier to implement.
    private BTreeNode[] childNodes;
    * A reference to the parent node of this node.<br>
    * This link is null if this node is the root node of the tree of BTreeNodes.<br>
    * This node is valid for both internal and leaf nodes.
    private BTreeNode parent;
    * The index in the parent node's array of links (the <i>childNodes</i> array) for the link to this node.<br>
    * This value should be set to -1 if this node is the root node (and so has no parent node).<br>
    * This field is valid for both internal and leaf nodes.
    private int parentIndex;
    * A link to the next leaf node in the B-tree, provided to allow easy sequential access of the keys
    * and values stored in the B-tree.<br>
    * This field is only valid if the node is a leaf node. For non-leaf nodes set the value to null.<br>
    * For leaf nodes, set the value to null if this node is the last leaf node in the B-tree.
    private BTreeNode next;
    * The link to the previous leaf node in the B-tree, provided ot allow easy reverse sequential access of the keys
    * and values stored in the B-Tree.<br>
    * This values should be set to null if this node is a leaf node but is the first leaf node in the B-Tree, or
    * if this node is not a leaf node.<br>
    * This field is only used in leaf nodes.
    private BTreeNode previous;
    * An array of comparable key objects that are stored in this node of the B-tree.<br>
    * Only the first <i>numberOfKey</i> values in the array are valid.<br>
    * The maximum number of keys in a node is 2*<i>order</i>, however there is space in this array
    * for one additional value to make the coding of the node splitting operation easier to implement.<br>
    * This field is valid for both internal and leaf nodes.
    private Comparable[] keys;
    * An array of data values associated with the keys stored in this leaf node of the B-tree.<br>
    * Only the first <i>numberOfKey</i> values are valid.<br>
    * The maximum number of data values in a node is 2*<i>order</i>, however there is space in this array
    * for one additional value to make the codingof the leaf node splitting operation easier to implement.<br>
    * This field is only valid for leaf nodes - for interior nodes this array is not created.
    private Object[] data;
    * A boolean value to indicate if the node is a leaf node or not. The structure of the remainder of the node
    * depends on this value (would be nice to have variant records in Java ...).<br>
    * This field is valid for both leaf and internal nodes.
    private boolean isLeaf;
    private int order;
    * The constructor for a BTreeNode.
    * <p/>The code for the constructor is provided - do not modify this constructor.
    * @param isLeaf True if this node is a leaf node.
    * @param parent A link to the parent node or null if this node is the root node of the B-Tree
    * @param parentIndex The index of the link in the array of child node linkes in the parent node that points to this node.
    * @param previous A link to the previous leaf node for sequentail access, or null if not a leaf node or no previous leaf nodes.
    * @param next A link to the next leaf node for sequential access, or null if not a leaf node or the last leaf node.
    public BTreeNode(boolean isLeaf, BTreeNode parent, int parentIndex, BTreeNode previous, BTreeNode next) {
    this.parent = parent;
    this.parentIndex = parentIndex;
    this.previous = previous;
    this.next = next;
    this.isLeaf = isLeaf;
    if (isLeaf)
    data = new Object[2 * order + 1];
    else
    childNodes = new BTreeNode[2 * order + 2];
    keys = new Comparable[2 * order + 1];
    public BTreeNode( int order, BTreeNode parent)
    this.order = order;
    this.parent=parent;
    this.keys = new Comparable[2*order-1];
    this.data = new Object[2*order-1];
    this.childNodes=new BTreeNode[2*order];
    this.isLeaf=true;
    * Returns the number of keys in this BTreeNode. Note that within the code in BTree you have access
    * to all the fields of BTreeNode, so this method is not strictly necessary.
    * @return The number of keys in this BTreeNode object.
    public int numberOfKeys() {
    return numberOfKeys;
    * Returns the container BTree object for this BTreeNode object. You may like to check that container objects
    * are the same when manipulating two BTreeNode objects.
    * @return the containing BTree object.
    public BTree container() {
    return BTree.this;
    * A private method to return a string representation of the array <i>keys</i>. This method is used in
    * the toString() method for this class.<br>
    * Do not modify the code provided for this method.
    * @return A string representation of this nodes array of keys.
    private String keyString() {
    StringBuffer s = new StringBuffer("{");
    for (int index = 0; index < numberOfKeys; index++)
    s.append(index > 0 ? "," + keys[index] : keys[index]);
    return s.append("}").toString();
    * A private method to return a string representation of the array of data values stored in a leaf node.<br>
    * This method is used in the toString() method of BTreeNode. The method does not check if this node is a
    * leaf node, as it is not intended to be called directly from outside of this class, and the toString()
    * method only calls this method if the node is a leaf node.<br>
    * Do not modify the provided code for this method.
    * @return a string representation of the data values array of a BTreeNode.
    private String dataString() {
    StringBuffer s = new StringBuffer("(");
    for (int index = 0; index < numberOfKeys; index++)
    s.append(index > 0 ? "," + data[index] : data[index]);
    return s.append(")").toString();
    * A private method to return a string prepresentation of the array of child node links in an interior node.<br>
    * This method is used in the toString() method. This method does not check if this node is an interior
    * node, so you must take care to only call this method for interior nodes.<br>
    * Do not modify the provided code for this method.
    * @return A string representation of the array of child nodes of this BTreeNode.
    private String childString() {
    StringBuffer s = new StringBuffer("<");
    for (int index = 0; index < numberOfKeys + 1; index++)
    s.append(childNodes[index] + (index == numberOfKeys ? "" : ","));
    return s.append(">").toString();
    * The toString method provides a string representation of a BTreeNode.<br> This particular method does not
    * include the details of all the fields of a BTreeNode. While debugging your code, you may like to include
    * more information (such as the parentIndex value), but in your final submission you must have the code
    * as provided in the skeleton BTreeNode class provided to you.
    * @return A string representation of a BTreeNode.
    public String toString() {
    if (isLeaf)
    return (new StringBuffer("[")).append(numberOfKeys)
    // .append(',').append(parentIndex) // uncomment this line if need to check parentIndex values
    .append(',').append(keyString()).append(',').append(dataString()).append(']').toString();
    else
    return (new StringBuffer("[")).append(numberOfKeys)
    //.append(',').append(parentIndex) // uncomment this line if need to check parentIndex values
    .append(',').append(keyString()).append(',').append(childString()).append(']').toString();
    * Returns the key with the given index in this node. Throws a BTreeError exception if the index is not valid.<br>
    * Do not modify this provided code.
    * @param index The index of the key.
    * @return The key value at the given index.
    public Comparable key(int index) {
    if (index < 0 || index >= numberOfKeys)
    throw new BTreeError("Key index out of range - value = " + index);
    return keys[index];
    * Returns the child node at the provided index into the childNodes array.<br>
    * A BTreeError exception is thrown if the node is not an internal
    * node or if the index is not valid.
    * <p/>Note that the child node returned will have keys that are all less than the key stored
    * in the <i>keys</i> array of this node at the given index value (except the last childNode
    * at index numberOfkeys, as this node has keys that are all greater than or equal to the last
    * key value stored in this node).<br>
    * Do not modify the provided code for this method.
    * @param index The index into the array of child nodes for this internal BTreeNode object.
    * @return The child node link.
    public BTreeNode child(int index) {
    if (isLeaf) throw new BTreeError("child() called for a leaf node");
    if (index < 0 || index > numberOfKeys)
    throw new BTreeError("Child node index out of range - value = " + index);
    return childNodes[index];
    * Returns the data value associated with the key at the given index. An BTreeError exception is thrown if the
    * node is not a leaf node or if the index is invalid.
    * <p/>Do not modify the provided code for this method.
    * @param index The index of the key assocaited with the data value.
    * @return The data value associated with the key with given index.
    public Object data(int index) {
    if (!isLeaf) throw new BTreeError("data() called for an internal node");
    if (index < 0 || index >= numberOfKeys)
    throw new BTreeError("Data index out of range - value = " + index);
    return data[index];
    * This method is used to determine if this node is a leaf node.
    * @return True if this node is a leaf node.
    public boolean isLeaf() {
    return isLeaf;
    * Inserts the (key, data) pair into this BTreeNode object.
    * <p/>You must supply the code for this method.
    * <p/>Implementation notes:<br>
    * <ol>
    * <li>Throw an exception if this node is not a leaf node.
    * <li>Scan the keys array for index of the key greater than or equal to the insertion key.
    * <li>If the key at the index is equal to the insertion key, update the data field and return - you are done.
    * <li>Otherwise shuffle the keys values from the insertion index along to make a hole for the insertion key,
    * and insert the insertion key into the keys array. Do the same for the data array values to insert the
    * new data value into the data array at the insertion index.
    * <li>increment the number of keys, and increment the container BTree object's count field.
    * <li>If the number of keys in the node is now no more than 2*order, you are done, so simply return.
    * <li>Otherwise the node has (2*order+1) key values, and need to split. The split operation leaves the first
    * <i>order</i> keys and data values in this node (and so the node's numberOfKeys value will become
    * <i>order</i>, and moves the remaining (order + 1) keys and data values to a new BTreeNode leaf node
    * that you need to create.<br>
    * You need to fix up the previous and next fields of this leaf node and the new leaf node you have created.<br>
    * Two sub-cases:
    * <ol>
    * <li>If this node is the root node (i.e., it does not have a parent node), the split of this node will create
    * a new root node, with a single key (the key at index (order+1)) and this node and the new BTreeNode as
    * the child nodes. In my solution I used a call to the method newRootNode to do this. The newRootNode()
    * method will also be used when a split of an interior node creates a new root node. See the JavaDoc for
    * details of what the newRootNode() method should do. Once the new root node has been created, and all
    * the fields updated due to the split, you are done.
    * <li>Otherwise we need to insert in this node's parent node the middle key (at index (order+1) and the
    * new node that we created. This is done by the method insertInterior(). The method is passed the
    * key to insert (at location this.parentIndex in the keys array of the parent node), the index to
    * to insert the key (this.parentIndex), and the new leaf node (that will be inserted at index
    * (this.parentIndex+1) in the parent node's child links array).
    * </ol>
    * </ol>
    * @param key The key to insert into the leaf node.
    * @param data The key's corresponding data value.
    public void insertLeaf(Comparable key, Object data) {
    // You need to provide the code for this method.
    // BTreeNode temp = new
    int size = this.data.length;
    int counter = 0;
    this.keys[size] = key;
    this.data[size] = data;
    sort(size);
    public int compareTo(Comparable o2) {
    // Integer o1 = (Integer) o2;
    return (((Integer)o2).compareTo(this));
    *split()
    *Splits a node into to nodes. This can only be done, if the node is full
    *The midlest key go up into the parent, the left ones of them rest in
    *this node, and the right ones go into a new node.
    private BTreeNode split(int order) {
    if (numberOfKeys == order*2-1) {
    BTreeNode right = null;
    if (parent == null) { // algo for the root-node
    BTreeNode left = new BTreeNode(order, this);
    right = new BTreeNode(order, this);
    for (int i=0; i<order-1; i++) {
    left.keys[i] = keys[i];
    left.data[i] = data[i];
    right.keys[i] = keys[order+i];
    right.data[i] = data[order+i];
    if (!isLeaf()) {
    for (int i=0; i<order; i++) {
    left.childNodes[i] = childNodes[i];
    left.childNodes[i].parent = left;
    right.childNodes[i] = childNodes[order+i];
    right.childNodes[i].parent = right;
    left.isLeaf = false;
    right.isLeaf = false;
    } else isLeaf = false;
    keys[0] = keys[order-1];
    numberOfKeys = 1;
    left.numberOfKeys = order-1;
    right.numberOfKeys = order-1;
    for (int i=1; i<order*2-1; i++) {
    keys[i] = null;
    data[i] = null;
    childNodes[i+1] = null;
    childNodes[0] = left;
    childNodes[1] = right;

    * Don't post that much code. There should never be a reason to. You should be able to break your code down into small enough pieces that you can post a small example that demonstrates your problem.
    * When you do post code, use [code] and [/code] tags to make it readable. You can use the code button on the message entry page.
    * The stack trace will tell you which line the NPE occurred on, where it was called from, where that was called from, etc. You can use that to help you find your error. Look at the line it's complaining about. What references are on that line followed by a dot, and what arrays do you try to access the elements of. One of those must be null.
    * Now that you know what[b] is null, put in a bunch of print statements to track [b]how it got to be null.

  • Writing JSPs to play chess; I get a null at a point, where I shouldn't

    I am writing a set of JSP pages in order to play chess online. I know it is better to do this task using an applet, but the man I am working for doesn't want it to be an applet. The idea is two clients play a game, while in fact manipulating a single object in the application or ServletContext object. If one of the clients makes a move - he modifies the Game object and the thread (a loop checking if the Game object has changed), created by the other client stops and his service method visualizes the move his opponent has made. As soon as a client submits a move - his service method creates and join()s the thread waiting for the next change in the Game object.
    MY PROBLEM IS: THE SECOND TIME THE HOST PLAYS A MOVE HIS OPPONENT GETS A NULL INSTEAD OF VALID Game OBJECT. CAN ANYONE TELL ME WHY BECAUSE I HAVEN'T SET IT TO NULL ANYWHERE IN THE CODE
    I have the following files: chessOnline.jsp, hostGame.jsp, joinGame.jsp, play.jsp, quitGame.jsp and a few .class files: Game.class, MovesStateChecker and GameOnChecker.
    chessOnline.jsp has two functions:
    1. to join a created game
    2. to create a new game
    joinGame.jsp and hostGame.jsp are just like play.jsp with the difference that they initialize the game; the code is quite the same.
    ---------------------------------------MovesStateChecker ----------------------------------------
    public class MovesStateChecker extends Thread
         private ServletContext sc;
         private int movesNumber;
         public MovesStateChecker(String name,ServletContext sc,int movesNumber)
              super(name);
              this.movesNumber=movesNumber;
              this.sc=sc;
         public void run()
              Game g=null;
              int retries=0;
              while(true)
                   try {
                        Thread.sleep(1500);
                   } catch (InterruptedException e) {}
                   g=(Game)sc.getAttribute(this.getName());
                   if(g==null){retries+=1;continue;}
                   if(g.getMoves().size()>movesNumber){break;}
    ---------------------------------------end of MovesStateChecker.class------------------------
    ---------------------------------------joinGame.jsp--------------------------------------------------
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.util.Map,java.io.IOException,chessoffice.*,java.sql.*" errorPage="" %>
    <%
    response.setHeader("Cache-Control","no-cache"); //Forces caches to obtain a new copy of the page from the origin server
    response.setHeader("Cache-Control","no-store"); //Directs caches not to store the page under any circumstance
    response.setDateHeader("Expires", 0); //Causes the proxy cache to see the page as "stale"
    response.setHeader("Pragma","no-cache"); //HTTP 1.0 backward compatibility
    %>
    <html>
    <head>
    <link rel="stylesheet" href="styles.css" type="text/css" />
    <title>Read</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <%
         if (Strings.dbCheckSession(request))
              String user =(String)session.getAttribute("sessionUser");
              if(request.getParameter("gameId")==null || request.getParameter("gameId").equals(""))
                   response.sendRedirect(response.encodeURL("/jsp/chessOnline.jsp"));
              else
                   Game joinedGame=(Game)application.getAttribute(request.getParameter("gameId"));
                   if(joinedGame.getBlack()==null)
                   {joinedGame.setBlack(user);}
                   else
                   {joinedGame.setWhite(user);}
                   joinedGame.setGameOn(true);
                   application.setAttribute(request.getParameter("gameId"),joinedGame);
                   MovesStateChecker msc=new MovesStateChecker(joinedGame.getId(),application,0);
                   msc.start();
                   msc.join();
                   Game g=(Game)application.getAttribute(request.getParameter("gameId"));
                   if(g==null)
                        response.sendRedirect(response.encodeURL("/jsp/chessOnline.jsp?error=opponentQuit"));
                   else
                        out.println(g.getWhite()+" - white player<br />");
                        out.println(g.getBlack()+" - black player<br />");
                        out.println(g.getMoves().size()+" - size of Moves array list (number of moves)<br />");
                        out.println(g.isGameOn()+ " - is the game on <br />");
                        out.println(g.getDesk().get("b2")+" - b2 position<br />");
                        out.println(g.getDesk().get("b4")+" - b4 position<br />--------------------<br />");
                        out.println("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
                        out.println("<tr><td>");
                        Read.drawDesk(false,g.getDesk(),out);
                        out.println("</td><td>");
                        Read.drawInfoForm(request.getParameter("gameId"),out);
                        out.println("</td></tr>");
                        out.println("</table><br /><hr />");
                        Read.drawQuitForm(request.getParameter("gameId"),out);
         else response.sendRedirect(response.encodeURL("/jsp/index.jsp"));
    %>
    </body>
    </html>
    ---------------------------------------end of joinGame.jsp-----------------------------------------
    ----------------------------------------hostGame.jsp-------------------------------------------------
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.io.IOException,chessoffice.*,java.util.*,java.sql.*" errorPage="" %>
    <%!
         public Map initGameMap() {
              Map m=Collections.synchronizedMap(new HashMap(64,(float)0.1));
              for(int ver=8;ver>=1;ver--)     {
                   for(int hor=0;hor<=7;hor++) {
                        switch(ver) {
                             case 1: m.put(""+Read.chars[hor]+ver,"white/"+Read.bfigs[hor]+".gif");break;
                             case 2: m.put(""+Read.chars[hor]+ver,"white/p.gif");     break;
                             case 7: m.put(""+Read.chars[hor]+ver,"black/p.gif");     break;
                             case 8: m.put(""+Read.chars[hor]+ver,"black/"+Read.bfigs[hor]+".gif");break;
                             default: m.put(""+Read.chars[hor]+ver,null);break;
              return m;
    %>
    <%
    response.setHeader("Cache-Control","no-cache"); //Forces caches to obtain a new copy of the page from the origin server
    response.setHeader("Cache-Control","no-store"); //Directs caches not to store the page under any circumstance
    response.setDateHeader("Expires", 0); //Causes the proxy cache to see the page as "stale"
    response.setHeader("Pragma","no-cache"); //HTTP 1.0 backward compatibility
    %>
    <html>
    <head>
    <script language="JavaScript" type="text/javascript">
         function selectFigure(cell)
              /*oldPos=cell.name;
              bgImage=cell.background;
              document.write(bgImage.substring(0,bgImage.indexOf("."))+"_"+bgImage.substring(bgImage.indexOf(".")-1,bgImage.length()));
              cell.background=bgImage.substring(0,bgImage.indexOf("."))+"_"+bgImage.substring(bgImage.indexOf(".")-1,bgImage.length());
              alert("cell name is: "+cell.background);
    </script>
    <title>chess online</title>
    <link rel="stylesheet" href="styles.css" type="text/css" />
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <%
         if (Strings.dbCheckSession(request))
              String user=(String)session.getAttribute("sessionUser");
              Game initialGame=new Game();
              initialGame.setId(user);
              if(request.getParameter("color")!=null)
                   if(request.getParameter("color").equals("white"))
                        initialGame.setWhite(user);
                   else
                        initialGame.setBlack(user);
              else
                   initialGame.setWhite(user);
              initialGame.setGameOn(false);
              initialGame.setWhiteTime(10*60*1000);
              initialGame.setBlackTime(10*60*1000);
              initialGame.setMoves(new ArrayList());
              initialGame.setDesk(this.initGameMap());
              initialGame.setCaptured(new ArrayList());
              application.setAttribute(initialGame.getId(),initialGame);
              GameOnChecker goc=new GameOnChecker(initialGame.getId(),application);
              goc.start();
              goc.join();
              Game g=(Game)application.getAttribute(user);
              out.println(g.getWhite()+" - white player (host)<br />");
              out.println(g.getBlack()+" - black player<br />");
              out.println(g.getMoves().size()+" - size of Moves array list (number of moves)<br />");
              out.println(g.isGameOn()+ " - is the game on<br />");
              out.println(g.getDesk().get("b2")+" - b2 position<br />");
              out.println(g.getDesk().get("b4")+" - b4 position<br />-------------------<br />");
              out.println("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
              out.println("<tr><td>");
              Read.drawDesk(false,g.getDesk(),out);
              out.println("</td><td>");
              Read.drawInfoForm(user,out);
              out.println("</td></tr>");
              out.println("</table><br /><hr />");
              Read.drawQuitForm(user,out);
         else response.sendRedirect(response.encodeURL("/jsp/index.jsp"));
    %>
    </body>
    </html>
    ----------------------------------------end of hostGame.jsp----------------------------------------
    ----------------------------------------play.jsp-------------------------------------------------
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="chessoffice.*,java.sql.*" errorPage="" %>
    <%
    response.setHeader("Cache-Control","no-cache"); //Forces caches to obtain a new copy of the page from the origin server
    response.setHeader("Cache-Control","no-store"); //Directs caches not to store the page under any circumstance
    response.setDateHeader("Expires", 0); //Causes the proxy cache to see the page as "stale"
    response.setHeader("Pragma","no-cache"); //HTTP 1.0 backward compatibility
    %>
    <html>
    <head>
    <link rel="stylesheet" href="styles.css" type="text/css" />
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <%
    boolean overtake=(request.getParameter("overtake").equals("true"))?true:false;
    String bgImage=request.getParameter("bgImage");
    String oldPos=request.getParameter("old");
    String newPos=request.getParameter("new");
    String gameId=request.getParameter("gameId");
    if(newPos!=null && oldPos!=null && bgImage!=null && gameId!=null)
         //tuk trqbva da ima proverka na hod-a
         //posle se suzdava obekt ot tipa Move i se zapisva v Game.moves:
         Move m=new Move(oldPos,newPos,overtake,bgImage);
         Game loadedGame=(Game)application.getAttribute(gameId);
         loadedGame.updateDesk(m);
         int currentMovesNumber=loadedGame.getMoves().size();
         application.setAttribute(gameId,loadedGame);
         MovesStateChecker msc=new MovesStateChecker(loadedGame.getId(),application,currentMovesNumber);
         msc.start();
         msc.join();
         Game g=(Game)application.getAttribute((String)session.getAttribute("sessionUser"));
         if(g==null)
              out.println("izvadenata igra e NULL");
              //response.sendRedirect(response.encodeURL("/jsp/chessOnline.jsp?error=opponentQuit"));
         else
              out.println(g.getWhite()+" - white player<br />");
              out.println(g.getBlack()+" - black player<br />");
              out.println(g.getMoves().size()+" - size of Moves array list (number of moves)<br />");
              out.println(g.isGameOn()+ " - is the game on <br />");
              out.println(g.getDesk().get("b2")+" - b2 position<br />");
              out.println(g.getDesk().get("b4")+" - b4 position<br />--------------------<br />");
              out.println("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
              out.println("<tr><td>");
              Read.drawDesk(false,g.getDesk(),out);
              out.println("</td><td>");
              Read.drawInfoForm(request.getParameter("gameId"),out);
              out.println("</td></tr>");
              out.println("</table><br /><hr />");
              Read.drawQuitForm(request.getParameter("gameId"),out);
    %>
    </body>
    </html>
    ----------------------------------------play.jsp----------------------------------------
    ------------------------------------------chessOnline.jsp----------------------------------------------------
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.util.*,java.io.*,chessoffice.*,java.sql.*" errorPage="" %>
    <%!
    public void drawJoinGameForm(javax.servlet.jsp.JspWriter out,ServletContext application) throws IOException
         out.println("<form action=\"joinGame.jsp\" method=\"get\">");
         out.println("<select style=\"width:300\" name=\"gameId\" size=\"6\" size=\"120\">");
         Enumeration e=application.getAttributeNames();
         while(e.hasMoreElements())
              String el=(String)e.nextElement();
              if(el.length()<=20 && ((Game)application.getAttribute(el)).isGameOn()==false)
              out.println("<option value=\""+el+"\" >"+el+"</option>");     
         out.println("</select>");
         out.println("<br /><input type=\"submit\" value=\"Join Game\" />");
         out.println("</form>");
    public void drawHostGameForm(javax.servlet.jsp.JspWriter out) throws IOException
         out.println("<form action=\"hostGame.jsp\" method=\"get\" name=\"hostGameForm\">");
         out.println("<input type=\"submit\" value=\"Host New Game\" />");
         out.println("<br />Choose your color:<br />");
         out.println("<input type=\"radio\" name=\"color\" value=\"white\" checked=\"checked\" /> White");
         out.println("<input type=\"radio\" name=\"color\" value=\"black\" /> Black");
         out.println("</form>");
    public void drawCancelForm(String user,javax.servlet.jsp.JspWriter out) throws IOException
         out.println("<form action=\"quitGame.jsp\" method=\"get\">");
         out.println("<input type=\"hidden\" name=\"gameId\" value=\""+user+"\" />");
         out.println("<input type=\"submit\" value=\"Cancel Game\" />");
         out.println("</form>");
    %>
    <%
         response.setHeader("Cache-Control","no-cache"); //Forces caches to obtain a new copy of the page from the origin server
         response.setHeader("Cache-Control","no-store"); //Directs caches not to store the page under any circumstance
         response.setDateHeader("Expires", 0); //Causes the proxy cache to see the page as "stale"
         response.setHeader("Pragma","no-cache"); //HTTP 1.0 backward compatibility
    %>
    <html>
    <head>
    <link rel="stylesheet" href="styles.css" type="text/css" />
    <title>Chess Online</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <%
         if (Strings.dbCheckSession(request))
              if(request.getParameter("error")!=null && request.getParameter("error").equals("opponentQuit"))
                   out.println("<br /><br />"+request.getParameter("error"));
              out.println("<table border=\"0\" align=center>");
              out.println("<tr><td rowspan=\"2\">");
              drawJoinGameForm(out,application);
              out.println("<br /><p>As soon as you join, your opponent, who is hosting the game, is on the move and your browser is waiting/loading.</p>");
              out.println("</td><td>");
              drawHostGameForm(out);
              out.println("</td><td>");
              drawCancelForm((String)session.getAttribute("sessionUser"),out);
              out.println("</td></tr>");
              out.println("<tr><td align=\"right\" colspan=\"2\">");
              out.println("<p>After hosting a game by clicking on the button 'Host New Game' your browser will be in process of loading a page."
              +" As soon as an opponent joins your game you will be able to make the first move. If you do not wish to wait any longer for "
              +"an opponent to join - click on 'Cancel Game'.</p>");
              out.println("</td></tr>");
              out.println("</table>");
         else response.sendRedirect(response.encodeURL("/jsp/index.jsp"));
    %>
    </body>
    </html>
    -----------------------------------end of chessOnline.jsp--------------------------------------------------
    I also have a Read.class - its name doesn't mean anything - I have stored some out.println(); operations there - drawDesk(...), drawQuitForm(...), drawInfoForm(...) etc.
    MY PROBLEM IS: THE SECOND TIME THE HOST PLAYS A MOVE HIS OPPONENT GETS A NULL INSTEAD OF VALID Game OBJECT. CAN ANYONE TELL ME WHY BECAUSE I HAVEN'T SET IT TO NULL ANYWHERE IN THE CODE

    This forum is about JMS, NOT JSP!!!

  • Performance Tuning in IR

    Hello All,
    We have created some reports using Interactive Reporting Studio. The volume of data in that Oracle database are huge and in some tables of the relational database are having above 3-4 crores rows individually. We have created the .oce connection file using the 'Oracle Net' option. Oracle client ver is 10g. We earlier created pivot, chart and report in those .bqy files but had to delete those where-ever possible to decrease the processing time for getting those report generated.
    But deleting those from the file and retaining just the result section (the bare minimum part of the file) even not yet helped us out solving the performance issue fully. Still now, in some reports, system gives error message 'Out of Memory' at the time of processing those reports. The memory of the client PCs,wherefrom the reports are being generated are 1 - 1.5 GB. For some reports, even it takes 1-2 hours for saving the results after process. In some cases, the PCs gets hanged at the time of processing. When we extract the query of those reports in sql and run them in TOAD/SQL PLUS, they take not so much time like IR.
    Would you please help us out in the aforesaid issue ASAP? Please share your views/tips/suggestions etc in respect of performance tuning for IR. All reply would be highly appreciated.
    Regards,
    Raj

    SQL + & Toad are tools that send SQL and spool results; IR is a tool that sends a request to the database to run SQL and then fiddles with the results before the user is even told data has been received. You need to minimize the time spent by IR manipulating results into objects the user isn't even asking for.
    When a request is made to the database, Hyperion will wait until all of the results have been received. Once ALL of the results have been received, then IR will make multiple passes to apply sorts, filters and computed items existing in the results section. For some unknown reason, those three steps are performed more inefficiently then they would be performed in a table section. Only after all of the computed items have been calculated, all filters applied and all sorts sorted, then IR will start to calculate any reports, charts and pivots. After all that is done, the report stops processing and the data has been "returned"
    To increase performance, you need to fine tune your IR Services and your BQY docs. Replicate your DAS on your server - it can only transfer 2g before it dies, restarts and your requested document hangs. You can replicated the DAS multiple times and should do so to make sure there are enough resources available for any concurrent users to make necessary requests and have data delivered to them.
    To tune your bqy documents...
    1) Your Results section MUST be free of any sorts, filters, or computed items. Create a staging table and put any sorts or local filters there. Move as many of your computed items to your database request line and ask the database to make the calculation (either directly or through stored procedures) so you are not at the mercy of the client machine. Any computed items that cannot be moved to the request line, need to be put on your new staging table.
    2) Ask the users to choose filters. Programmatically build dynamic filters based on what the user is looking for. The goal is to cast a net only as big as the user needs so you are not bringing back unnecessary data. Otherwise, you will bring your server and client machines to a grinding halt.
    3) Halt any report pagination. Built your reports from their own tables and put a dummy filter on the table that forces 0 rows in the table until the report is invoked. Hyperion will paginate every report BEFORE it even tells the user it has results so this will prevent the user from waiting an hour while 1000s of pages are paginated across multiple reports
    4) Halt any object rendering until request. Same as above - create a system programmically for the user to tell the bqy what they want so they are not waiting forever for a pivot and 2 reports to compile and paginate when they want just a chart.
    5) Saved compressed documents
    6) Unless this document can be run as a job, there should be NO results stored with the document but if you do save results with the document, store the calculations too so you at least don't have to wait for them to pass again.
    7) Remove all duplicate images and keep the image file size small.
    Hope this helps!
    PS: I forgot to mention - aside from results sections, in documents where the results are NOT saved, additional table sections take up very, very, very small bits of file size and, as long as there are not excessively larger images the same is true for Reports, Pivots and Charts. Additionally, the impact of file size only matters when the user is requesting the document. The file size is never an issue when the user is processing the report because it has already been delivered to them and cached (in workspace and in the web client)
    Edited by: user10899957 on Feb 10, 2009 6:07 AM

Maybe you are looking for

  • Airport Utility instant crashes when i open it.

    Can this have happened because i deleted some files using daisy disk? Process:         AirPort Utility [668] Path:            /Applications/Utilities/AirPort Utility.app/Contents/MacOS/AirPort Utility Identifier:      com.apple.airport.airportutility

  • Bitmap text show wrong accents

    Hello, I have this problem with text set to bitmap text rendering. With fonts like pixel fonts like standard 07_51, Kroeger etc. I can't get them to show the right accents (éèà...). This shows on stage and in runtime and it occurs with static, dynami

  • Similar To Ken Burns - But it looks like only the subject is being zoomed in and the background is staying where it is?

    Hi there Obviously I dont know the correct term for this otherwise I'd google it, but I see this effect more and more on "Making Of" special features. It makes it look like a person, or obejct is moving (in towards the camera/screen) within a static

  • WiFi speakers

    I have been using my laptop to listen to my music, using my iPod touch as a remote -- love the convenience. I am wondering if any of the speakers I have seen work with WiFi, in other words, letting me plug the speakers into the power in one room and

  • I cannot log onto Adobe site

    My safari won't let me log onto Adobe site. Any body know why this would only happen with this site? I tried to reinstall operating system but it hung up. I suppose I'll have to use Chrome to get to site. I've tried everything, to clear Safari Cookie