Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!

maneesh subherwal

Ranch Hand
+ Follow
since Aug 26, 2002
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 maneesh subherwal

I agree with everything that has been said here: putting values in the session that do not really need to be there is a no-no and no one should usually do that. Of course memory management is important and that also goes back to the fact that the session should not contain irrelevant information.
Thank you,
Maneesh
16 years ago
I usually look at this very closely since I am under the impression too that session objects are expensive to handle for the web server. I have tried to find more information on how vendors (IBM, for one) handles the session objects so that I have a clearer idea about how they are stored and how expensive the session data actually is but to no avail.
Moreover, as Bear mentioned, the stale objects always seem to be an issue and if a session is not invalidated explicitly by the user, the data hangs around until the session timeout value is exceeded.
I usually clean up the session objects once I know, for sure, that I will not need them anymore and also create them if and only if I need the value on multiple pages.
Also, another question that may be helpful would be: Is the overhead the same for storing this object in the session the same as the overhead for creating a new object and storing it into the request everytime a request is made? I believe if there a multiple uses for the same object value, the value should be stored in the session.
Thanks,
Maneesh
16 years ago
yes it seems to work fine.
16 years ago
It sounds to me like the compiled version that is referenced on your html page is an old copy. Try deleting that class and recompile the class file. I tested it and it works exactly as the code states. It draws a red rectangle when rectangle is clicked and a blue circle when the circle button is clicked.
Thanks,
Maneesh
16 years ago
i just ran your code myself and it seems to be running fine too... compilation issue? runtime issue?
16 years ago
to make it easier to understand, here is what is should say:
dia=Integer.parseInt(diaField.getText()); // the int has been removed
thanks,
Maneesh
16 years ago
same issue with int dia in the actionperformed method. removed int since you are assigning a new local variable instead of the global variable. I tested this and it works.. you also need the braces i mentioned earlier and all the other fixes that Ernest Friedman-Hill mentioned too.
hope this helps...
Maneesh
16 years ago
your class should return something back to the servlet indicating success or failure. Based on that flag, the servlet could either forward to an appropriate jsp or use the response writer to output required html.
hope this helps
Maneesh
16 years ago
you need braces for one, for the lines below (like this):
if(flag==1)
{
g.setColor(Color.red);
g.fillRect(xcord,ycord,len,wid);
}
if(flag==2)
{
g.setColor(Color.blue);
g.fillOval(xcord,ycord,dia,dia);
}
hope this helps...
Maneesh
16 years ago
Basically setting an attribute to a request can only be accessed by the request whereas the session attribute can be accessed between multiple requests. A good example would be a shopping cart - the users shopping items could be stored in the session. Within this application, if a form needs to be submitted (e.g. you have a page that requests user comments) could be accessed using a request attribute.
hope this helps...
Maneesh
16 years ago
i think Andy is correct about sessions being passivated when they are not being used for sometime to free up resources. However, I think the major use is when the sessions are migrated from one server to another. The sessionwillpassivate is called in the first server and the sessionDidActivate is called in the second server. This is used when serialized objects exist in the session. If you do contain an object in the session that contains transient values, I believe they will not be transferred over.
I hope this helps.
Thanks,
Maneesh
application.xml specifies war files and other application level contexts. An application is nothing but a bunch of war files. For example an enterprise application project would specify the ejb war and the web project war file.
the web.xml holds a lot more detailed information for the war file. It includes the web app name, servlet mapping, security roles, application context values, and lots of other information.
I hope this helps...
Maneesh
16 years ago
Andy,
The HttpSessionActivationListener is used for monitoring sessions on the server. When a session is activated, Notification that the session has just been activated will be received by the SessionDidActivate Method and when the session is about to be destroyed, the sessionWillPassivate is used.
Objects that are bound to the session can be initialised or destroyed based upon the listener. Also, when the session migrates between servers, the sessionwillpassivate is called and once it is successfully moved, the sessionDidActivate will be called. It is interesting to note that the sesssion is not yet ready for service at the time the sessionDidActivate method is called.
hope this helps...
Thanks,
Maneesh
No Problem Andy.
The onUnload Method should work with netscape too... however, I have only tried it with IE and it works with no problem. If you find another solution, do let me know...
Thanks,
Maneesh
I believe that the last function that is compiled by the page will be called. The last function compiled here is second.js' order() function.
Interestingly, javascript does not overload methods as well. A javascript function can be passed any number of arguments when it is invoked.
hope this helps...
Thanks
Maneesh