Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Loop issue in ExceptionHandlerServlet

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to handle non-business exception in the BPIMSExceptionHandlerServlet . So I make a BPIMSExceptionHandlerServlet class below.


And my web.xml file is:


Now I just create one NullPointerException in one Action class manually.


When I run the project, the BPIMSExceptionHandlerServlet catched the NullPointerException. But the problem is the program keep running. It seems a loop in doPost method. It just keeps running. I have debug the project. The program keep running from the first line to the last line in doPost method. Anybody know what's wrong here? Thanks in advance.
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just a wild guess, change the name of html file


into


Afterthoughts: It look like this part of the code is recalling the ExceptionHandlerServlet

OR you may have some unhandled Exception in ExceptionHandlerServlet code, itself
 
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
Not sure what this has to do with Struts.Is that really what you mean to do?

In any case, the ability to redirect also depends on not having written anything to the response yet.
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:
In any case, the ability to redirect also depends on not having written anything to the response yet.


Yes, David is more precise than me :thumbup:
 
Haifeng Jiang
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sagar Rohankar wrote:

David Newton wrote:
In any case, the ability to redirect also depends on not having written anything to the response yet.


Yes, David is more precise than me :thumbup:



Thanks for your reply.

Now I correct the code.

but the program cannot find the error.html file. Give me a 404 error code. I also tried "error.html" or "/error.html". none of them work. Now I don't know what is the correct path in the sendRedirect() method. Do you know how to write in the method?

My project structure is:
BPIMS_Web --- WebContent --- WEB-INF --- jsp --- common --- error.html
- --- welcome.jsp
error.html and welcome.jsp are in the same directory.

In the application.xml:


I use below url to access my project:
http://localhost:9080/partnerworld/incentives/management/welcome.wss?user=eric
when I click one link in the welcome page to trigger the exception to throw out to the servlet level, the servlet can catch the exception. But the redirect method doesn't work. Kindly advise.
 
Haifeng Jiang
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I got the solution. Add one Action in the struct config file to handle the redirected uri. Then redirect to the url which you want.
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why don't you try Exception Handling + Struts. Struts provides Global exception handling for your web app.
 
Haifeng Jiang
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sagar Rohankar wrote:Why don't you try Exception Handling + Struts. Struts provides Global exception handling for your web app.


As you may know if the jspException throwed from jsp level. Struts will not able to cacth this type of exception. So I have to think out a solution to handle it. Thanks
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eric Jiang wrote:

Sagar Rohankar wrote:Why don't you try Exception Handling + Struts. Struts provides Global exception handling for your web app.


As you may know if the jspException throwed from jsp level. Struts will not able to cacth this type of exception.


Hmm, I know about jspException, but never cared about it, Anyways, thanks.
 
Haifeng Jiang
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sagar Rohankar wrote:

Eric Jiang wrote:

Sagar Rohankar wrote:Why don't you try Exception Handling + Struts. Struts provides Global exception handling for your web app.


As you may know if the jspException throwed from jsp level. Struts will not able to cacth this type of exception.


Hmm, I know about jspException, but never cared about it, Anyways, thanks.



welcome.
Now I do a test. If I create NullPointerException manually in jsp. the servlet cannot catch it. Don't know why. Anybody can help on this?Thanks.
reply
    Bookmark Topic Watch Topic
  • New Topic