I want to download the file, whatever the type of the file may be. If i select to download the doc type file, it should open in the word doc only, but not in the notepad.

Christopher Koenigsberg

On the server side, you can only set the MIME content-type in the response, and hope that the client browser is configured to open that content-type with the application you want.

For example, the content-type for a Microsoft Word document is "application/msword". (you can find a list of them for instance in the overall "web.xml" for any Tomcat server installation).