Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

jesal dosa

Ranch Hand
+ Follow
since Jun 25, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by jesal dosa



The problem was the property and name variables were wrongs


Cannot believe i did not spot that
Some one please help me. I am going throw the head first Servlet and JSP.

I am trying to do the some of the useBean attributes example from the book.

I hope some can help. I cant seem to figure out what is wrong.

I have the following two classes







I have the following the jsp


I keep getting the following error in tomcat


Thanks K. Tsang. I was playing with the eclipse settings and it was using the correct version for the ant javac call. Thanks I will add both the jre and jdk versions in the version.txt

thanks
So close yet so far. I am just writing the version.txt file

The instructions state

indicating the exact version of JDK you used, and the host platform you worked on.



I have been using the Eclipse IDE and Ant to build the runme jar file. My confusion is that eclipse apparently uses its own Java compiler and i am not sure what the ANT javac option is using to build and compile the classes. I am running the ant build under a separate JRE called jdk1.6.0_13

I am testing the application under the latest the JRE

java version "1.6.0_13"
java(TM) SE Runtime Environment (build 1.6.0_13-b03)
java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)

I have been looking at some post on goggle and here but i cant seem to figure what i put in the version.txt

Do i put jdk1.6.0_13 or jre java version "1.6.0_13"

Some please help and hopefully I can finally submit this.
Hi K.Tsang,

The client only ever get a copy of the Remote Service implementation. The data class only exists on the server.

I only expose the book and search methods. So when ever the VM is going to shut-down it calls the clean up code through the a thread which is run through the implementation of Runnable interface which is created as inner class in the Data class. So its got access to the Random Access file and therefore it can close it.

When the Ctrl -c or system.exit(0) is called then the shutdown hook code is called.
Hi Roel,

I have seen a post where people have skipped this and you have cemented this idea to let be and let go of it. Thanks for the advice. Ill leave it has is.

Thanks
Hi Roel,

Thats the big money question.

I dont care about locked records, if something goes wrong the client will get a message with error connecting to server. All i am worried about is any writes that are talking place when this shutdownhook is called.

I could have something like a flag, Before a write method like update, delete set the flag to true and the change it back to false once its finished. When the hook is called check the flag if its false else waits for bit before and then shut down.

Is this design acceptable?
At the moment in my locking code I just have recNo which are mapped to threads. i dont have any -1 which locks the whole database, which some people seem to have implemented. I am still not sure how to confirm there are no writes happening before the data file is closed. Do I even really have to worry about this or can i get away with it when I call the shutdownhook?
In the Data class i have implemented the shutdown hook


when the data object is created in the constructor it creates a

thread object which creates inner class using the Runnable interface this has access to the data random access file. I create my clean up code in the run method and then i use



when ever the application is going to shutdown, this code will run
yes I am using a service layer its only got two method book and search.

The booking does
database.lock
database.update
database.unlock its in a finally block
Dear all, I hope some one can help. I have added a shutdown hook like suggested in my Data class, what this does is close the RandomAccess file and make it point to null.

The things that i am still confused about is my update and delete methods in my database are synchronized. So what would happen if the database closes the file during an update option.

This may seem like a dumb question but if the update method is synchronized i assume it will not close the file. i am at a point were i am so close to finishing i don't want to make any mistakes.

Also since the booking is done in lock book unlock method even if it is unsuccessful it should be handled correctly from the client prospective.

Is what i have specified in the shutdown hook in enough or am i missing something important


server shutdown

the following link suggests i can get away without actually worrying about server shutdown but I think i will implement the database file shutdown in a finally() method but not worry about anything else
Hi K Tsang,

I was'nt closing the file in the local mode. So I assume if I just have a finally() method in the data class which closes the file, like you mention in the previous post that will solve all my problems.
Hi All,

I am nearly coming to the end, i hope. I have been searching some posts on ways to handle server shutdown.

The two main options i have a come up with are either to use the Runtime.addShutdownHook or use the finalize() method.

i don't have a server gui. after the initial start up it reverts back to the console.

Now to do a clean exit i think the only thing i need to go is close the database file,

What i am not sure is do i need to write the finalize in the data class or the server class, my main concern is i am not sure what i need to clean up, because the booking record is done in one atomic step, so i am not really sure what i need to clean up when the server is shutdown

server shutdown

Thanks K. Tsang and Andrew,

this clears it up. Sorry for the initial incorrect posting.

King Regards

Jesal