JSP is displayed by default errors, but this usually makes people feel unstable, but it is inevitable in the first period of software that is started to use. At the same time, this reaction is abnormal when it is running many times, not true procedures, but incorrect operation, like password is not right or conditional; may be called conditional notice. Throw an exception in the program, just to save the machine. I have been trying to organize a set of error-oriented ways that can be universally, I hope to meet the following requirements: First, you can save real error messages to debug use; second, if it is an operative error, you can notify the user to operate the error type The third is to guide the specific page. Fourth, whether it is servlet or JSP, there should be the same encoding method for programming consistency. V. Edit is simple.
Obviously, this requires a simple messaging mechanism. It is not necessary to use JMS. It is also a relaxed thing to merge with JSP various components; Struts's ErrorS is such a message system, which can also be satisfied required. Using this method is approximately to generate a collection of error messages in session / request, then check it through a label. HTTPServeletRequest has a SenderRors method, which is an information error that is usually seen 404, but this is unreliable. This time I use a simple JSP trial, it seems that everything is normal, but once it is embedded in the complex interface, I will die in the middle of the road, so all eliminated - I can't know what the complex and simple boundaries are there, can only be one Vote veto. In the end, confirming the ERRORS mechanism of integrated Struts should be the most cost-effective. Here, I changed ErrorS, no longer the redirect to a fixed display error message, but to notify the user mainly by popping up the Alert message box. It seems that the effect is good; the code is only four lines; but the existing program is changed, I changed me for two or three hours. Use this set of ways basically reach four basic requirements.
Original: http://zwwwxy.blogchina.com/blog/Article_81038.693446.html