• 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

Printing Error Stack Trace in JSP

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

I want to print the entire error stack trace in JSP page using Struts. In other words, if some goes wrong in Action then there should be a JSP page which should be able to show entire stack trace. But I don't why is it not working?

I tried following methods but none of them worked
[list]In struts-config.xml:
[/list]
  • Add an entry in your ApplicationResources.properties. Something like:
    error.generic = Arghh! Something blown up !
  • Created a JSP which contains <html:errors/>


  • I don't know why am I not getting the error stack trace on JSP ?

    I know some other ways to do this but I don't wanna make it (Please forgive me for these horrible, dirty clutters )

  • Put Error Stream in request and print the stream
  • Configure 404 and 500 in web.xml (not sure whether will work)

  • ....
    ... etc (Wicked Ideas... )

    Thanks in Advance !


     
    Author
    Posts: 12617
    IntelliJ IDE Ruby
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    html:errors won't show a stack trace, it's just for showing simple messages. Just put the exception into scope and access it in the JSP.

    But putting a stack trace on the user side isn't really a great idea.
     
    Fidel Edwards
    Ranch Hand
    Posts: 243
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    David Newton wrote: Just put the exception into scope and access it in the JSP.



    I know this way. But for this I will have to put Error Stream in scope, in every catch statement. It may lead to lot of copy-paste.Could you suggest some other ways?

    David Newton wrote:
    But putting a stack trace on the user side isn't really a great idea.



    I know David, it is a bad idea. But I am doing something for my purpose only. Please don't mind it :)
     
    David Newton
    Author
    Posts: 12617
    IntelliJ IDE Ruby
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Maybe a custom request processor--Struts can handle declarative exception handling, so it must be doable.
     
    Fidel Edwards
    Ranch Hand
    Posts: 243
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    David Newton wrote:Maybe a custom request processor--Struts can handle declarative exception handling, so it must be doable.



    Thanks David,

    If I understood it correctly then inside catch block of my Custom Request Processor I should put exception in scope and print that exception in JSP.Simple...right?

    Please correct me If I am missing something.
     
    David Newton
    Author
    Posts: 12617
    IntelliJ IDE Ruby
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    More or less, yes. You might not even need to do that if you can define an exception handler; see:

    http://struts.apache.org/1.2.9/userGuide/building_controller.html#exception_handler
    http://struts.apache.org/1.2.9/api/org/apache/struts/action/ExceptionHandler.html

    That would be one step removed from having to customize a request processor, and would let you tap in to the existing declarative exception handling process.
     
    Fidel Edwards
    Ranch Hand
    Posts: 243
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    David Newton wrote:More or less, yes. You might not even need to do that if you can define an exception handler; see:
    That would be one step removed from having to customize a request processor, and would let you tap in to the existing declarative exception handling process.



    Thanks David,

    It is working find for me. Meanwhile, I also found an interesting link after looking into your links

    http://www.visualbuilder.com/jsp/struts/tutorial/creating-custom-exception-handlers-in-struts-1/

    Thanks a lot for resolving the issue.
     
    Whip out those weird instruments of science and probe away! I think it's a tiny ad:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic