I am just developing a servlet application, in which my client request me that when there is anyone try to view source via his web browser, it should be nothing to view. However, how to do it with servlet?!
I have found that although I have try it with setting the header-cache, it does works. What should I do so as to meet the requirement? As I remember, there was some webpages that on Sun's website have this ability, however, I couldn't find it now.
First of all why would you want to do such a thing?
If you are worried about someone copying your code, then keep the bare minimum code on the client side and do all the processing on the server.
I am not saying there would not be a way to avoid that, there might be one. But is it worth taking so much pain for something which is really not so important?
If you are refering to the source code on the server of course he can't see it. If you are refering to anything that is downloaded to the clients machine there is nothing in the world that will stop the person from seeing it if they want to. You are sending information to another computer and that information is now completely out of your control. If you sent information to someone why in the world would you not want them to see it. If you are worried about special javascript code I wouldn't be as no matter how special it is you can probably find something similar on the web for free anyways. If it is that special then use a java applet in a jar file where they will only be able to disassemble it and not see the source code.
Actually, there are a lot of of java decompilers wich will translate the byte code into .java files without any problems. There is no secure way to disable a browser to see the source code of your page (java script, applets or anything else)