1. I don't know the way.

2. I don't know how.
----------------------
Are both grammatical? Can we use both?

Yes, they are both correct and frequently used.