This is just simple. Suppose I have some file handling code in my servlet page. Now if there is some problem in the file handling, then I want to log the user out and then get him/her to the usual exception page, then I have two options, either I use this type of code
Now the respective error page defined in the web.xml file will be called. But if I want to show a different error page than declared in the web.xml, then I'll just forward the request in the catch block
The request attributes are just to make sure that any normal error page can be displayed. Since these are the attributes that are automatically set by the servlet container in the first example, so
you should set them in the second case to maintain consistency. But you are not forced to do this. This is just a convention. I can create an error page which is not dependent on these attributes and then I'll not need to set these attributes. This is why the question is like this-
which of the following attributes would you set in the request?