aanal jethalia

Greenhorn
+ Follow
since Nov 16, 2006
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 aanal jethalia

I wrap the Exception with my application specific Exception and throw it again. Thats why I catch and throw.

Thanks for your help.
14 years ago
Hi

I have a class which has a static method that takes a String classname and returns the instance of type class. My method looks like:

public static <T extends Object> T getClassInstance(String className) throws Exception{
T instanceToReturn = null;

try {
Class c = Class.forName(className);
instanceToReturn = (T)c.newInstance();
} catch (InstantiationException e) {
throw e;
} catch (IllegalAccessException e) {
throw e;
} catch (ClassNotFoundException e) {
throw e;
}
return instanceToReturn;
}

I get the following warning:

Type safety: The cast from Object to T is actually checking against the erased type Object. Should I be worried about this warning? How can I avoid it?

I am very new to Generics, so am not sure if this is the correct way to use it. Any help would be great.

Thanks
Aanal
14 years ago
thanks all....i was thinking of taking this exam almost 6 months back but never got around to finishing all the objectives...i didnt know about Head First until 2 weeks ago....i started reading a few other books....and i was never able to read more than 2-3 chapters and whatever I read always vaporized....i guess i should have done more research on the reading material and also i should have joined javaranch much earlier....i probably might be preparing for a SCBCD test right now anyways....i am happy i found Head First....even if it was just 2 weeks ago...
for filter 2 and filter 4 instead of <url-pattern> element there is <servlet-name> element in Head First. Filter chain will have the matching url-patterns first and then the matching servlet-name.
thanks Max....I havent worked a lot in jsp servlets...my focus was more on weblogic workshop....jpfs

I studied for around 6-8 hrs a day everyday...one week i spent in reading head first and another for mock tests...went thru the servlets jstl and jsp specs....and ya i also bought the epractice exam from sun....am not sure if they were really helpful...

also i made notes from each chapter in head first and stick them on walls all over the apartment...it really helped me revise everything i studied...anyway good luck for your test...
hey all....I passed scwcd...got 86%...am very happy....i studied for just 2 weeks...feels like quite an accomplishment....thanks to all at java ranch for their questions and answers...links and replies to all my questions and doubts...

i was promised an apple macbook pro notebook if I clear the exam....can anyone here tell if macbook pro is good for java developers....the configurations look appealing....or should i just stick to dell or probably get viao..bye
I found this on Jiris

The four methods for session management in the context of web-based application are: Cookie, HttpSession object, URL rewriting and Hidden value.

Is the above statement true? Should it not be SSL instead of HttpSession object?
doGet() will process HEAD requests in the absence of a doHead() method.
Cool....I am happy I was right....I found this question on one of the epractice exams I bought from sun's website...so had doubts about my understanding.....thanks for the confirmation
I came across the following question in the sun epractice exam:

Given a JSP page with the line:
<jsp:useBean id="cust" type="test.beans.CustomerBean" scope="session" />
Which two occur? (Choose two.)

A A CustomerBean instance is created if the attribute name cust is not found.
B The session is searched for a CustomerBean stored as the attribute name cust.
C The CustomerBean instance is populated with the values of the parameters in the request.
D A CustomerBean instance is always created and stored in the session with the attribute name cust.
E The CustomerBean identified by cust is located in the application and then stored in the session for later use.

The correct answers stated are options A and B.

But I am doubtful about option A being correct. If we only use the "type" attribute and if the bean doesnot exist, does the container not throw an InstantiationException?

Please let me know if I this is the case. Thanks
Hi

If we have a useBean, with say id="test", and the test bean exists in the default scope, I know that having setProperty in this action's body will not be invoked.

How does the setProperty action behave when this action (for useBean test) is put outside the useBean body? Will it reset the earlier value with the new one?

as in how would the following code work?
<jsp:useBean id="test" class="someClass"/>
<jsp:setProperty name="test" property="testProp" value="some value"/>

I hope I made my question clear.
Thanks
Hi

If we have a useBean, with say id="test", and the test bean exists in the default scope, I know that having setProperty in this action's body will not be invoked.

How does the setProperty action behave when this action (for useBean test) is put outside the useBean body? Will it reset the earlier value with the new one?

as in how would the following code work?
<jsp:useBean id="test" class="someClass"/>
<jsp:setProperty name="test" property="testProp" value="some value"/>

I hope I made my question clear.
Thanks