1. The parent page sets up a timer that calls the child.jsp every second
2. The child.jsp increments the value of j by one and returns HTML code containing the incremented value
3. The jQuery .load() replaces the <div id="load_me"> ... </div> with the HTML generated by child.jsp
4. Repeats every second.
There are few comments to make with regard to the code and some things that don't make sense.
- The session variable JVal should be set first in the parent not the child.
- Its not clear why you have are storing the value of i in the session, it is not retrieved again by parent.jsp as this page in not being reloaded.
- perhaps to maintain this value so that it can be incremented. For this you would need to get the session value before incrementing, which you are not doing.
- The code
will not be evaluated again unless the parent page is reloaded, which is not what you are doing.
- The Child.jsp returns a complete HTML page when all you need is the new value. This can be better achieved with a servlet.
Something like this:
Try to rewrite the code a bit and let me know what happens.
PS: When posting code use encoding to make the code easier to read. Thanks.