Prabhat Ranjan

Ranch Hand
+ Follow
since Oct 04, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
3
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 Prabhat Ranjan

I am answering-
If parent bean has scope singleton then child bean should always be singleton even if we write the scope of child bean to prototype in context.xml file.

Child inherits and overridden the properties of parent in spring.
9 years ago


9 years ago
What about if we use the generics types and apss the child class instead of Parent type Animal was defined

method(Dog);

instead of the method argument was initally <Animal>

what will happen?
9 years ago
Thanks , i mean to say we should not downcast if in this case Animal is not a dog.
9 years ago
Hi All,

is the Java upcating and downcasting rules are same for general object type or generics types?

1) Dog dog = new Animal();

Type mismatch can't covert Dog to Animal - complie time error

2) Animal animal = new Animal();
Dog dog = (Dog) animal;

java.lang.ClassCastException: Animal cannot be cast to Dog at runtime.

Please comments.

rgds,
Ranjan
9 years ago
Hi All,

Lets see,

Parent Bean A has singleton Bean --> Child class will be by default if not defined.

Parent class is Prototype --> Then child class is singleton --> will this work.

So what is the rules of the scope of inheritance in spring if parent bean has differnt bean and then child is by default?

rgds,
ranjan
9 years ago
1) new keyword , String str = new String();

1) new
2) clone
3) class.forName().newInstance()
4) deserilization of serilized object
5) Factory Method --> using BeanFactory in spring or SessionFactory in Hibernate
6) loading object in web.xml or config file wither in first request or early loading while application startup

I know 6th one might uses the reflection methods similar to class.forName using classLoader.

Hope this is now fine.

9 years ago
My answer is below one.

1) New()
2) Clone()
3) class.forName().newInstance()
4) deserilization of serilized object
5) Factory Method --> using BeanFactory in spring or SessionFactory in Hibernate
6) loading object in web.xml or config file wither in first request or early loading while application startup
I know 6th one might uses the reflection methods similar to class.forName using classLoader.

Please comments any one who is expert and used fully.
9 years ago
Yes, i mean singleton is basically used not to create multiple instance of the class.

but is there any way to create multiple instance lets say cloning() or any another..

9 years ago
Hi All,

Please can anyone tell me , how many ways to break singleton in Java?

Regards,,
Prabhat
9 years ago
Hi All,

Is there any difference between IOC and DI or both are same?

Regards,
Prabhat
10 years ago
somthing more if we have EJB then it will come to service layer to use some business logic for application.
10 years ago
Thanks Joe..

I also investigated and below is the understanding

Action calls -> Controller Action Servlet class --> calls the service method of BO( like getCustomerService() of class CustomerService for BO Customer) --> calls DAO in this case it is CustomerDAO interface for getCustomer() method --> calls DAOImpl in this case CustomerDAOImpl (DB connection and persistence logic) --> DB calls

Controller Servlet --> free to ask about the service of BO( Customer) that is getCustomerDetails etc..
Customer POJO --> used as DTO to hold the data and nothing knows about the controller,DAO or Service Layer
Service Layer --> contains the service calls including business logic as per business requirement or validation at this level just to check the instance is customer or not before persisting the data into db.
Persistence layer --> connection to db , update,save,select query using either JDBC,JDBCtemplate,Hibernate,JPA

let me know if my understanding is better than last time.

Thanks,
Prabhat
10 years ago
I have resolved my problem, action context path was in-correct in form.

thanks Bear.

Regards,
Prabhat
this is working now, i did R &D and re-build the project, i can see the files are complied on classes folder.

One more problem , when i hit the action button on submit , it calls servlet and servlet name with URL mapping are configured on web.xml , not sure getting the error 404


http://localhost:8080/WEB-INF/classes/ControllerServlet


HTTP Status 404 -
type Status report
message
description The requested resource is not available.


web.xml servlet are as below -

<servlet>
<servlet-name>s1</servlet-name>
<servlet-class>com.javatpoint.ControllerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>s1</servlet-name>
<url-pattern>/ControllerServlet</url-pattern>
</servlet-mapping>


what is the problem that web container doesn't find the ControllerServlet.class from classes folder under the package?