File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

usebean and catching constructor exception

 
mark weitz
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a case where I am using a third party bean and want to do a use:bean in my jsp. During the constructor method of the bean it attempts to connect to a server. If the connect is unsuccessful, an error is thrown. In my case, if I can't connect, that's ok, I just want to hide a button on the web page.
Unfortunately, if an error is thrown, I get a 500 rather than my webpage.
Is there a way to catch a exception thrown by a constructor when doing a use:bean?
Mark
 
Jack Wiesenthaler
Ranch Hand
Posts: 75
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The bean is not designed correctly... the constructor is meant to create and initialize the **object**, not perform business or other logic. There should've been a separate method called connect() to do that.
I guess you just have to instantiate the bean yourself with Beans.instantiate() or new() and catch the exception.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic