aspose file tools*
The moose likes Struts and the fly likes web.xml error-page throws exception on s:text Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "web.xml error-page throws exception on s:text" Watch "web.xml error-page throws exception on s:text" New topic
Author

web.xml error-page throws exception on s:text

Santosh Sb
Greenhorn

Joined: Nov 04, 2009
Posts: 10
Hello Folks,

I have 2 questions -

Question 1. Does struts global-exception-mappings not handle exceptions in JSP?



If I get an error in jsp page it never goes to the genericError.jsp


Anyway, I created an error-page in web.xml



Question 2. Now if there is a jsp error, the servlet container redirects it to the error500.jsp

I have an s:text in error500.jsp that gets the text from MessageResources.properties. But the s:text throws a NullPointer exception



Looks like it is not finding the stuff on ValueStack.

I had the exact same error in the struts global-exception-mappings. If the action class throws an exception, struts routes it to the genericError.jsp. The s:text tags in genericError.jsp just blow up with NullPointers. Strange. Any words of wisdom from gurus?

Thanks!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

If you redirect to a JSP then the request isn't handled by Struts 2, hence no value stack, hence using Struts 2 tags won't make much sense.
Santosh Sb
Greenhorn

Joined: Nov 04, 2009
Posts: 10
Sorry, I misquoted.

I don't think the servlet container is redirectling to the error500.jsp. The address on the browser address bar never changes.
Santosh Sb
Greenhorn

Joined: Nov 04, 2009
Posts: 10
If I put a debug on ComponentTagSupport.java: line 49



when the control comes to the error500.jsp on the s:text line, I can see that the component variable on line 2 above has the OgnlValueStack and the root attribute inside it has the exact same instance of the Action class that it had when the request first started.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Is the error message different if you create a JSP with an <s:text> tag in it and access the JSP directly? I don't recall. If it's a different error message then I suspect something else tricky is occurring.

"Gyrations" is a quite unusual last name: does it comply with the JavaRanch naming policies?
Santosh Sb
Greenhorn

Joined: Nov 04, 2009
Posts: 10
Thanks for your reply David.

I pulled the error jsp out of the WEB-INF and put it inside the WebContent, accessed the jsp directly from the browser and the s:text worked fine. Honestly, I didn't know it was supposed to work that way too.

I should also mention that the application uses sitemesh Any thoughts? Is struts global-exception-mappings supposed to handle exceptions thrown by JSP.

I really appreciate your time.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Hmm, I guess the message lookup doesn't depend on a value stack.

I'm not sure why the dispatcher instance wouldn't exist in this case, but I'm guessing it's still an issue with the way exceptions are handled. You might want to try on the struts-user mailing list and see if someone more familiar with this part of S2 has an idea.
Santosh Sb
Greenhorn

Joined: Nov 04, 2009
Posts: 10
Sure. Thanks David.
 
Consider Paul's rocket mass heater.
 
subject: web.xml error-page throws exception on s:text