aspose file tools*
The moose likes Struts and the fly likes Loop issue in ExceptionHandlerServlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Loop issue in ExceptionHandlerServlet" Watch "Loop issue in ExceptionHandlerServlet" New topic
Author

Loop issue in ExceptionHandlerServlet

Haifeng Jiang
Ranch Hand

Joined: Dec 14, 2008
Posts: 42
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.


Thinking a lot. Gaining a lot.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

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

[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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

Joined: Dec 14, 2008
Posts: 42
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

Joined: Dec 14, 2008
Posts: 42
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

Why don't you try Exception Handling + Struts. Struts provides Global exception handling for your web app.
Haifeng Jiang
Ranch Hand

Joined: Dec 14, 2008
Posts: 42
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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

Joined: Dec 14, 2008
Posts: 42
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Loop issue in ExceptionHandlerServlet