• 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

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

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
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
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
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
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
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
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
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
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
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure. Thanks David.
 
reply
    Bookmark Topic Watch Topic
  • New Topic