• Post Reply Bookmark Topic Watch Topic
  • New Topic

Throw custom exception in jsp page..

 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

suppose i want to throw a custom exception..and i should that in the error jsp page..

how can i..since the method signature in a jsp page after converting to a servlet would be ...

throws ServletException,java.io.IOException


there wont be my custom exception...

Regards
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At this stage of the game you shouldn;t be doing any type of processing in JSPs that would require throwing exceptions. You really want to conside adopting modern best practices and move processing out of JSPs.

That said, you can wrap your custom exception as the root cause of a JspException and throw that.
[ November 05, 2007: Message edited by: Bear Bibeault ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The short answer is that you shouldn't be using JSP for anything that would need to throw custom exceptions. (Look a the MVC example in our code barn for an alternative).

That being said, Java exceptions can be chained.
This allows you to wrap any exception in a ServletException.

 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Even i agree with the fact...that we should leverage the latest stuff...
jstl,etc... but the app is a legacy j2ee1.3 app..

Regards
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!