8 Replies Latest reply on Mar 31, 2009 8:38 AM by ndrw_cheung

    customized error page question

    ndrw_cheung

      Hi, all. I have a web application running inside JBOSS Portal (portal version 2.4, app. server version is 4.0.5) inside a portlet. In the web application, I use try/catch to trap the exceptions, and I would like to redirect the page to an error page if those exceptions are caught.

      In the myApp.war/WEB-INF/web.xml, I have:

      <error-code>500</error-code>
      /WEB-INF/jsp/error.jsp
      </error-page>
      <error-page>
      <exception-type>java.lang.Exception</exception-type>
      /WEB-INF/jsp/error.jsp
      </error-page>
      <error-page>
      <exception-type>javax.faces.FacesException</exception-type>
      /WEB-INF/jsp/error.jsp
      </error-page>
      <error-page>
      <exception-type>javax.faces.el.EvaluationException</exception-type>
      /WEB-INF/jsp/error.jsp
      </error-page>

      On the error page, I have :


      <%@ page isErrorPage="true" %>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>



      this is error page



      However, it doesn't seem that the configuration is being picked up. Am I missing something?

      Note that I only want the error redirection for this web application to go to the error.jsp page only, so I don't want to put this configuration in the web.xml in the tomcat55 folder.

      Any help is appreciated. Thanks.

      -Andrew


        • 1. Re: customized error page question
          peterj

          What gets displayed to the user depends on the portal, not on an individual portlet. A portal page can contain many portlets so showing an error page because one portlet has an issue is typically not what it done. You could, however, display some kind of error message within the portlet itself.

          JBoss Portal does give some control over how it should behave when a portlet runs into a problem. Look at the control.portal.* and control.page.* properties in the jboss-portal.sar/conf/data.default-object.xml file.
          http://docs.jboss.org/jbportal/v2.7.0.B1/referenceGuide/html/errorhandling.html

          Oh, by the way, when posting XML text or source code, please enclose the text in "code" tags - you can do this by selecting the text and clicking the Code button above the editor window. Also, click the Preview button to ensure that the formatting is correct and the XML text shows up before posting. If you don't do this, the forum will not filter your input and instead give it to the browser which will assume that you have given it html tags to interpret.

          • 2. Re: customized error page question
            ndrw_cheung

             

            "PeterJ" wrote:


            JBoss Portal does give some control over how it should behave when a portlet runs into a problem. Look at the control.portal.* and control.page.* properties in the jboss-portal.sar/conf/data.default-object.xml file.
            http://docs.jboss.org/jbportal/v2.7.0.B1/referenceGuide/html/errorhandling.html


            I'm using portal version 2.4 - I couldn't find the control.portal.* nor control.page.* in the said default-object.xml file. Likewise, there isn't an equivalent chapter on error handling configuration in the version 2.4 documentation either. Anything I can do to configure custom error handling?

            BTW, thanks for the tips regarding posting code.

            -Andrew

            • 3. Re: customized error page question
              peterj

              Sorry, I completely overlooked the fact that you stated which version you are using. For 2.4.x, look at jboss-portal.sar/conf/config.xml.

              • 4. Re: customized error page question
                ndrw_cheung

                 

                "PeterJ" wrote:
                Sorry, I completely overlooked the fact that you stated which version you are using. For 2.4.x, look at jboss-portal.sar/conf/config.xml.



                Thanks for the pointer. However, does that mean that ALL web applications I have for the portal (I only have 1 portal) will follow this configuration? Can I have a different error handling configuration for each web application? (i.e. MyApp1.war goes to MyApp1/WEB-INF/jsp/MyApp1Error.jsp when error is encountered, and MyApp2.war goes to MyApp2/WEB-INF/jsp/MyApp2Error.jsp.)

                Also, I have seen a lot of posts about configuring the web.xml file with error-page tags. What is that used for?

                -Andrew

                • 5. Re: customized error page question
                  peterj

                  The entire portal, and all of it's pages and portlets, will follow that single configuration.

                  The information about error-page tags is for web applications, not for portals or their portlets.

                  • 6. Re: customized error page question
                    ndrw_cheung

                    Thanks again Peter.

                    So back to the config.xml file in jboss-portal.sar/conf : There is no way in version 2.4 of the portal I can specify that I want jsp to handle the error, and that it should redirect the error to a specific jsp page just like the way that version 2.7 does. Is this correct?

                    In that case, how can I tell the system which jsp page is the error page I want to use?

                    -Andrew

                    • 7. Re: customized error page question
                      peterj

                      From what I recall from playing with the various options in config.xml about 2 years ago, when a portlet runs into an error (that it, it throws an exception which is caught by the portal) you can either:

                      a) have the portlet not be displayed
                      b) show only the exceptions error message within the portlet window
                      c) show the full exception stack trace in the portlet window

                      As far as I know, there is no way to tell the portal to display an error page if one of the portlets faults.

                      Instead of having the portlet fault (throw an exception), you can have the portlet code catch the exception and redirect the portlet's output to a JSP that will show an error message within the portlet's window. Note that in this case the portal assumes that the protlet completed successfully.

                      • 8. Re: customized error page question
                        ndrw_cheung

                         

                        "PeterJ" wrote:

                        Instead of having the portlet fault (throw an exception), you can have the portlet code catch the exception and redirect the portlet's output to a JSP that will show an error message within the portlet's window. Note that in this case the portal assumes that the protlet completed successfully.


                        I tried this and it works. Thanks a lot.

                        -Andrew