At present I am exploring though how database Sharding works in Mongo DB.
My use case is I have number of products like electronics/baby prods/books/cloths etc. in my web application. Say i want to store different products on different DB(on different machine) to distribute the load and scale up if required.
My question is the responsibility of Mongo DB to store the product in right DB based on product type and my webserver java code will be completely unaware of it ? Does Mongo DB supports this ?
Or it will be the responsibility of webserver java code to connect to correct DB to store the product based on its type ?
Yes, MongoDB supports what you describe. Sharding in MongoDB is how MongoDB allows scaling out/horizontally scaling. It requires a shard key which is what is used to decide which shard a document (a product in your case) in a sharded collection will end up on. It sounds like you would like to use product type as your shard key. MongoDB takes the responsibility of directing documents to shards based on shard key. With reference to the linked web page, your web server will connect and send queries to mongos query router instances which will route queries to shards appropriately based on shard key.
Choice of shard key should not be taken lightly though. If chosen poorly, almost all queries can end up going to a single shard. Read about how shard key factors such as cardinality, frequency, and rate of change can impact shard performance here.