A Phatak

Greenhorn
+ Follow
since Sep 22, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
6
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by A Phatak

I have the following Struts 2 xml


Everything else is coded correctly and all the specified actions run properly.
However...

http://localhost:8080/StrutsApp/chapterFour/login and http://localhost:8080/StrutsApp/anythingElse/login and http://localhost:8080/StrutsApp/login
all redirect to the login page.

Is that how this is supposed to work?
9 years ago
What is the code in the Servlet that allows you to get the count of activeSessions. I suspect you are stuffing this in the session.setAttribute("activeSessionCOunter", activeSessions);

However, you will need another static method that returns this session counter


Now you can try this code in multiple browsers ...Chrome, IE, Saffari, or from multiple computers

I figure you will see number increase as sessions join!

jami siva wrote:I created below Listener to track how many sessions are created. However, If I open number of browsers the below sessionCreated() method is executed only once. I thought every brower request treated as a seperate session. If it is true, below sessionCreated() method will call for every newly created session(In this case for every new browser request). Please let me know whether my understanding is right or wrong.

And how to test the below HttpSessionListener.




Thanks,
Siva

I am studying from the K&B Head first book for this exam. I am also fairly new to JSPs.
K&B book very conveniently skips from initParameter("...") to get/set Attributes in application scopes.

Take a look at page 310 bottom part of the page, where she uses getServletConfig().getInitParameter("email") and stuffs it as an attribute value into servletContext.

Am I missing something? Are we not supposed to access getServletContext().getInitParameter() in a JSP. The reason I am asking is there is no mention of this in the EL section either.
The attribs are directly being accessed as ${application.attrib_name} but no initParameters ever get access this way (or even within <%= %>


I can understand this kind of an approach in an MVC scenario, perhaps the servletConfig param value will not be available in a view_jsp after it got forwarded to from a servlet. So a servlet might have to stuff it as a request/context attribute. But....??

Thanks for the answer
Have you tried setting sessionid in secure cookie?
That way, you will not be able to recreate the request using session info, becuase you will be checking the cookie info as well.
10 years ago
I keep having some trouble understanding synchronizing concept in the context of static vs nonstatic. For e.g. take a look at the code below:


It is a simple listener that counts number of active sessions. However, we know HttpSession object is not thread safe. So I believe that "counter" variable should be incremented in a "synchronized" manner.

It is clear that getCounter() should change to public synchronized static int getSessionCounter()

My question is what changes should be implemented in sessionDestroyed() and sessionCreated() methods? Which of the following is correct?



OR




Or does it have to be synchronized at all?
10 years ago
Sorry if this is a wrong place for this question? I am studying for the OCEWCD and thought this is my forum. If not please redirect me appropriately
I keep having some trouble understanding synchronizing concept in the context of static vs nonstatic. For e.g. take a look at the code below:


It is a simple listener that counts number of active sessions. However, we know HttpSession object is not thread safe. So I believe that "counter" variable should be incremented in a "synchronized" manner.

It is clear that getCounter() should change to public synchronized static int getSessionCounter()

My question is what changes should be implemented in sessionDestroyed() and sessionCreated() methods? Which of the following is correct?



OR




Or does it have to be synchronized at all?
Oracle WCD Exam Objectives Link

I have begun studying for this exam, and was looking thru the forum for study material and resources. I understand the K&B head first book is the favorite and i am using it. Problem is it is outdated per the objectives listed in the link above.

Anyone who recently appeared for this exam cares to help?

All help is greatly appreciated!
I want to finish OCP WCD and OCP WS (not too keen on EJBs)


fadi aboona wrote:congrats A Phatak!! what's next?

I'm on the last chapter of K&B and i plan to read the book one more time then do the questions on the cd that came with the book, also the mock questions on the website you posted to identify my weak points.

10 years ago
Buy the K&B book first [People also recommend Programmer's guide to SCJP by Khalid Mughal]
Read thru' the book; I found, on avg it takes 3 hrs to finish each chapter, give or take, with complete concentration. Generics & Collections chapter needs to be split into 2 or 3 parts.
For me, I did not do any of the exercise questions till I finished my first full reading. Once the book was completed, I did the exercise questions for ch.1, undertstood why I got things wrong, then read ch1 again with complete concentration. This time, while reading, I found out that everything I got wrong is completely explained in the book at some point or the other, I had just missed it on my first pass. During the 2nd reading, note oddities, rules, and make sure you code these small programs in as many different ways as you can. Each time, make note of the output and jot down the rules the compiler is following.


After the second reading get a mock test package like Enthuware or Whizlabs. Also "like" OCP JP Success" on facebook.

DO as many Exam type questions as you can. By about 2 months of doing this, you will feel confident that you can pass the exam. You'll know it when you are ready!
Best of luck

Tariq Kamardeen wrote:@phatak

Congrats dude

I am also preparing for OCP-JP 6. As per most of the suggestions and yours I planned to take mock test using Enthuware.

How much does it costs to take test? And what are the steps to take test. I have no idea what to do. Help me!

I wanna know whom should I approach to take test.

Thanks in advance.

10 years ago

O. Ziggy wrote:

What does the second 'L' stand for?



L = Left

so say you have a something like


Now run this code under several scenarios


This is not meant to confuse you, just simply stating my way of remembering things....
10 years ago
I do not know what you mean. This is my first exam, on Java, so if you are asking whether it changed from 310-065, I have no clue. If you are asking me if it is close to EnthuwareMock Exams, I found all exams were similar in toughness factor and format factor to the exam. I don't particularly like exams, so I get jitters even for a driving exams.

Amar Amarendra wrote:Congratulations Dear!!!
i know about the ocp jp have any changes after oracle take over,please tell me.

10 years ago
I don't like it that Oracle wants you to appear for OCP-JA as a prerequisite OCP-JP.
What do they think, money grows on trees? That's why I will not be upgrading!
I did not do exam-lab. I did the first 30 questions from Exam Lab and my heart sank!

I did go over the K&B book very well. I had some prior Java experience. I did do the Enthuware tests, and if you "like" Whizlabs on facebook (search OCPJP Success) you will get a question bank of about 20-to-30 questions. The actual exam has very similar questions.

I did not find the actual exam easy. So do not underestimate it if someone tells you it is easy. (of course this is personal opinion!)
A heartfelt word thanks to fellow ranchers! I have looked for and found resources, advice on studying and, not the least, got answers to all my silly questions without a word of reprimand or condescension! I passed OCP-JP with 86% today and I have am still feeling the euphoria.

A few pointers to all those who want to appear for this exam:
- K&B Certification book is a must. There is nothing on the exam that is outside of this book. All concepts are explained well with a hint of humor. I read the book once, did the questions, found out where I was going wrong, then read it again this time underscoring my weak points. By the end of second time I felt I understood the "why"s of everything well. Do not stop reading till you understand the concepts given here and compliment the K&B book by actually coding.

- While coding I made sure to make notes of compiler rules. I made mental associations (e.g. right-side, runtime (R & R) and left-side, compile-time (L & L) for how the VM will make a choice to run the method in a case like SuperClass s = new SubClass(); s.overridden_method(); ...what happens to private methods, what to static methods, variables, casting, to give you an idea). I know I remember by association, so that helped me. I had a LOT of questions on Auto-Boxing, and which methods get called at runtime vs compile time

- While coding I made sure to note rules for autoboxing on a paper, for last-day exam cram. I got a lot of convoluted questions on the exam on this topic.
- I drew all the diagrams for GCing objects, by creating reference vars and drawing arrows to Objects on heap. Helped me identify the island question on the test
- After reading the K&B book and solving practice questions after each chapter, I moved on to Enthuware. I never got more than 77%
- I also did a lot of questions from Facebook-like-Whizlaps (they have a library of free questions if you like them (OCPJP Success) on facebook)
- A lot of questions from game2.jsp on coderanch (Google it)

I got about 10 questions on Generics and Collections, Sorting and Comparable/Comparator (remember there is no "to" in the comparable interface, so the method is compareTo(Object obj)), and about 6 on Threads, and 4 on command line args/packages/imports, 4 on file/IO

All in all, the exam is certainly not a piece-of-cake; but it is certainly doable if one remains focused. I used full 2+ hrs for review. I am not the one to finish exam early anyway.

Best of luck to all everyone whose exams are coming up...
10 years ago