What is the good approach to forward the exception from servlets to a jsp page?

前端 未结 2 547
太阳男子
太阳男子 2020-12-03 16:31

I know I can put something in the web.xml like this

  
   java.lang.Throwable  
   

        
2条回答
  •  萌比男神i
    2020-12-03 17:03

    yes, In my opinion session is a good place to store exceptions relating to the current request.

    Don't forget to clear the exception after you finish handling it.

    Also, you can pass instead of exception, an error code from your backing code to your presentation layer, where that can be translated using property files to some kind of meaning full error for the user.

提交回复
热议问题