• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SHowing the Exception back to the JSP from DAO Layer

 
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the UI , i am clickiing a function that will actually call this method inside the DAO Layer . Now please tell me how can i get access to this exception under my JSP to show to the User , if this exception comes



 
Bartender
Posts: 543
4
Netbeans IDE Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can throw it (or some other, homecooked RuntimeException) to the Servlet and put it in your session/request. You can also bubble it up and throw an exception in your servlet that will redirect you to the assigned error jsp, and you can access the exception object from there.

Not a good idea to show too much exception information to the end user, though. Personally, I'd just put an exception message label with an empty request attribute in your jsp, and if the exception occurs, redirect to the same jsp and set a descriptive String to the request attribute. But that's just me.
 
Greenhorn
Posts: 21
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The best way to show error messages for end user,just make string object and return from the DAO layer function to jsp
And the jsp has to produce your own textual based message to end user.
This is easy and best option for web related projects instead of exception.
 
Greenhorn
Posts: 3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I personally dislike the idea of showing too much error information to the user, because most users won't be interested in a stacktrace (well...except maybe hack3rz).
But on the other hand, as a developer I would like to see the whole stacktrace quick without digging into some logfiles on the server.
So in order to hide details, you could throw up the exception, define a error-page in your web.xml
and in your error.jsp comment out the stacktrace by putting something like this (uses JSTL):
So you just have to view the webpages sourcecode to see the full stacktrace, and the 'normal' user won't be confused by too much information

HTH
Jans
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic