Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

hatim osman

Ranch Hand
+ Follow
since Jun 10, 2005
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 hatim osman

Hi...
I have read the elegant example included in HFSJ book with respect to filters and wrappers. It compressed the response using a custome wrapper. It largely depended on the finish() method of the GzipOutput stream to intercept and control the transmission of the response.
Using wrappers, are there any other ways to prevent the response from being automatically sent to the client, assuming compression is not required?

Thanks
Hi
Amit , do you mean to say that sessions sruvival across shutdowns and restarts is mandatory by the specification or it is vendor specific?
In case of tomcat, does a call to a session getter method returns a new sessoon or fetch that "maintained by the container" if the applicaition crashes after acquiring a session and then restarts?

I still find it confusing!
Hatim
Hi...
Thank you very much guys, all my doubts are cleared now. I have come along way in believing that the book is correct. But practical application made me think twice.
Hatim
Hi there�
I have some doubts regarding JSP tag <c:set>. P. 447 of HFSJ book includes the following:


I you do not use the optional �scope� attribute in the tag, and you�re using �var� or �target�, the container will search scopes in the order you�ve come to expect-page � page, then request, then session, then application (context)
If you use �var� version without a scope, and the container can�t find an attribute of that name in any of the four scopes, the container makes a new one in page scope.




Then please explain to me why the following code is not working correctly:

Servlet code

JSP code

The JSP outputs :
Mark
Mark
Rather than
John
John

Why is that? The� name� variable exists in the request forwarded by the servlet. The JSP went on and created a new attribute in page scope and assigned the value �John� to it. In other words, <c:set> tag didn�t search all scopes. Only checked the default scope �page�, and when didn�t find a variable named �name� it automatically created one and refrained from checking other scopes.
A similar scenario applies to <jsp:useBean> tag, when the type attribute is used without �class�, <jsp:useBean> doesn�t search all scopes when the �scope� attribute is not used. Thus choosing the third option as an answer �as the book did� for the exercise in page 356 is incorrect.
Any clarification?
Hatim
Hi there...
while in this topic, using the seMaxAge() method, how can I make my cookie live at the client machine forever until physically removed by the client?
in other words, what is the value that should be passed to setMaxAge() method?
Thank you in advance
Hatim
10 years ago
Hi...
From the "servlet life cycle" perspective the following two phases are different;

1. Construction: in this phase the container merely creates an instance of your "class" by calling the constructor.
2. Initialization: here where the container grants the created instance the priviliges and benefits of becoming a servlet, and this take place in the init() method.

You may add some code in your contrctor to initalize the created instance, but you will not be able to access any servlet features as they the instance is not initalized yet.

Hatim
Hi..
thank you very much guys, the matter is very clear to me now.

Hatim
Hi there...
Here is what I understood from HFSJ book and correct me if I am wrong:
"The 'isElIgnored' attribute of the 'page' directive is meaningful, if and only if, the 'el-ignored' element of the DD is sepecifed"

In otherwords, can we use 'isELIgnored' without specifing the default behavior in the DD, or is 'isELIgnored' only used to override the default behavior and must be used in conjunction with the DD element?

thanks in advance
hatim
Hi there.
Now, if class Obj implements the HttpSessionBindingListener, what is the order of notification when the following code executes:


I am amazed because when I kept track of the listener methods (on Tomcat), I found the order of notification the following:
Bound-Bound-Unbound
and I have expected:
Bound-Unbound-Bound
Does anybody have an explaination?
Thank you in advance
Hatim
SCJP, SCJD
10 years ago
hi
It is very shocking to me! I never expected that servlets and jsp are moving out of the market.
Hi
Just like java command-line arguments, enclose your value between quotes ("") whenever there is a space between an argument, and in your case attribute. Hence the following should work without problems:

Servlet Code


JSP Code


Good Luck
Hatim Osman
SCJP, SCJD
10 years ago
Hi there
Is there way I can monitor a particular folder, new files added, renamed or deleted? I want so some sort of a listener, if possible of course.

thank you
10 years ago
Hi there,

I gained alot from this post, especially that I suffered similar problems many times. I have a final question though, assuming that the servlet classes reside in the default package, or folder, "classes/", what are the urls that correspond to the following mappings, particularly when trying to invoke either servlet through a relative url:



and


Thank you very much in advance
Hatim
10 years ago
Hi there...

I am computer science graduate currently in Riyadh, I am also a SCJP and SCJD. Currently I am moving toward web application devlopment using servlets and JSP. I am looking for chances to apply my knowledge. I wonder where I can find intermediate level open source projects.
In addition, it's been a year since I met a java programmer in Riyadh which has really slowed down my learning pace. I really want to start a group of freelance Java programmers in Riyadh, there are many prjects here and I just can't accept them due to the unavailability of man-power.

Thank you in advance
10 years ago
Hi
What am I missing here:



Now I made sure that the byte[] transimitted over the socket connection changes at the other point, meaning, data at client side (after encryption) is never data at server side (before decryption). Any clues or suggestions.

Thanks,
10 years ago