Error Page in JSP Having Problems.

Hi all,
I am having some issues with error pages in JSP.
I am trying to display one simple error image when my JSP is having any kind of error, let’s say when it throws any exception. Here goes the code…
throwError.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page errorPage="errorPage.jsp"  %>
<html>
<body>
Hello All,
<%! int x = 12/0; %>
</body>
</html>errorPage.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page isErrorPage="true" %>
<html>
<body>
<img src="error.jpg" height="100" width="100">
</body>
</html>web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
     <error-page>
     <error-code>500</error-code>
     <location>/errorPage.jsp</location>
     </error-page>
     <error-page>
     <exception-type>java.lang.ArithmeticException</exception-type>
     <location>/errorPage.jsp</location>
     </error-page>
</web-app>Please see if you can help…
Currently when I run the throwError.jsp in Eclipse, nothing happens. It shows "500 Internal server error". But the error.jpg doesn't appear on browser. I have copied the error.jpg properly in the WebContent folder of the Web App root.
Thanks much...
Goldest

Raghu,
You need to fix your syntax:
<%=someObje.getNo()>
not
<=someObje.getNo()>
Your concept of how to use error.jsp seems correct.
--BobC                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Generating error page(in jsp) when session expires....

    hello,
    i want to generate error page(in jsp) when session get expires...
    plz help me out.............

    You could do it according to the line BalusC supplied in another topic:
    <meta http-equiv="refresh" content="<%= session.getMaxInactiveInterval() %>;url=login.jsp">The only thing you gotta change, is the URL, make it:
    <meta http-equiv="refresh" content="<%= session.getMaxInactiveInterval() %>;url=error.jsp">Create 'error.jsp' and have the message 'Session expired, sorry!' or something printed. If you want to use error.jsp for more than just the session expiration, add a parameter to it:
    <meta http-equiv="refresh" content="<%= session.getMaxInactiveInterval() %>;url=error.jsp?error=sessionexpired"> Place the following lines in your error.jsp:
    String errormessage = request.getParameter("error");
    if(errormessage.equals("sessionexpired")){
    out.println("Your session has expired, sorry!");
    }else if(errormessage.equals("whatever")){
    // To do code here.
    }

  • Tomcat, custom error page, sendError and encoding problems

    Hi All!
    I have the following code in my index.jsp page:
    <%
        if(hasParent && !imageStore.contains(parent))
            response.sendError(404, "Requested image with id=" + parent + " was not found on this server");
            return;
    %>following in the web.xml:
    <error-page>
        <error-code>404</error-code>
        <location>/404.jsp</location>
    </error-page>Both pages (index.jsp and 404.jsp) are windows-1251 encoded:
    <%@page contentType="text/html; charset=windows-1251"%>But I have an issue: all non-latin characters are mangled when 404.jsp displayed as the result of calling response.sendError.
    I mean, if I open myserver.com/404.jsp or myserver.com/non-existing-document-la-la-la, everything is okay. But when I open myserver.com/index.jsp?parent=123 it calls response.sendError - text is mangled.
    What's even more bizarre, Tomcat sends the right encoding in the response headers, but with ? instead non-latin characters:
    HTTP request sent, awaiting response...
    1 HTTP/1.1 404 Requested image with id=1231231 was not found on this server
    2 Content-Type: text/html;charset=windows-1251
    3 Date: Sat, 16 Sep 2006 18:14:27 GMT
    4 Server: Apache-Coyote/1.1
    5 Connection: Keep-Alive
    22:14:27 ERROR 404: Requested image with id=1231231 was not found on this server
    .I am using Apache Tomcat/5.0.28.
    I understand that this issue is not trivial, but I would appreciate any ideas.

    Hi All!
    I have the following code in my index.jsp page:
    <%
        if(hasParent && !imageStore.contains(parent))
            response.sendError(404, "Requested image with id=" + parent + " was not found on this server");
            return;
    %>following in the web.xml:
    <error-page>
        <error-code>404</error-code>
        <location>/404.jsp</location>
    </error-page>Both pages (index.jsp and 404.jsp) are windows-1251 encoded:
    <%@page contentType="text/html; charset=windows-1251"%>But I have an issue: all non-latin characters are mangled when 404.jsp displayed as the result of calling response.sendError.
    I mean, if I open myserver.com/404.jsp or myserver.com/non-existing-document-la-la-la, everything is okay. But when I open myserver.com/index.jsp?parent=123 it calls response.sendError - text is mangled.
    What's even more bizarre, Tomcat sends the right encoding in the response headers, but with ? instead non-latin characters:
    HTTP request sent, awaiting response...
    1 HTTP/1.1 404 Requested image with id=1231231 was not found on this server
    2 Content-Type: text/html;charset=windows-1251
    3 Date: Sat, 16 Sep 2006 18:14:27 GMT
    4 Server: Apache-Coyote/1.1
    5 Connection: Keep-Alive
    22:14:27 ERROR 404: Requested image with id=1231231 was not found on this server
    .I am using Apache Tomcat/5.0.28.
    I understand that this issue is not trivial, but I would appreciate any ideas.

  • Problem displaying error page of web.xml when using JSF, Ajax4jsf

    Hi,
    My application is using MyFaces, RichFaces and Ajax4jsf. When i try to display error page configured in web.xml, i am getting exception "Error while processing error page".
    my web.xml contents are as follows:
    <?xml version="1.0"?>
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <filter>
    <display-name>RichFaces Filter</display-name>
    <filter-name>richfaces</filter-name>
    <filter-class>org.ajax4jsf.Filter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>richfaces</filter-name>
    <servlet-name>faces</servlet-name>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
    </filter-mapping>
    <filter>
    <filter-name>extensionsFilter</filter-name>
    <filter-class>
    org.apache.myfaces.webapp.filter.ExtensionsFilter
    </filter-class>
    <init-param>
    <description>
    set the size limit for uploaded files. Format: 10 - 10 bytes 10k
    - 10 KB 10m - 10 MB 1g - 1 GB
    </description>
    <param-name>uploadMaxFileSize</param-name>
    <param-value>100m</param-value>
    </init-param>
    <init-param>
    <description>
    Set the threshold size - files below this limit are stored in
    memory, files above this limit are stored on disk.
    Format: 10 - 10 bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB
    </description>
    <param-name>uploadThresholdSize</param-name>
    <param-value>100k</param-value>
    </init-param>
    </filter>
    <filter>
    <filter-name>Seam Redirect Filter</filter-name>
    <filter-class>org.jboss.seam.servlet.SeamRedirectFilter</filter-class>
    </filter>
    <filter>
    <filter-name>KTServletFilter</filter-name>
    <filter-class>com.kenexa.core.system.KTServletFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>extensionsFilter</filter-name>
    <url-pattern>*.jsf</url-pattern>
    </filter-mapping>
    <filter-mapping>
    <filter-name>extensionsFilter</filter-name>
    <url-pattern>/faces/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
    <filter-name>Seam Redirect Filter</filter-name>
    <url-pattern>*.jsf</url-pattern>
    </filter-mapping>
    <filter-mapping>
    <filter-name>KTServletFilter</filter-name>
    <url-pattern>*.jsf</url-pattern>
    </filter-mapping>
    <!-- seam Listeners -->
    <listener>
    <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
    </listener>
    <listener>
    <listener-class>com.kenexa.kr.web.KRServletListener</listener-class>
    </listener>
    <servlet>
    <servlet-name>faces</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>faces</servlet-name>
    <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    <error-page>
    <exception-type>java.lang.Throwable</exception-type>
    <location>/rc/systemError.jsf</location>
    </error-page>
    </web-app>
    As per the configuration, when exception is thrown out of the application, container tries to display systemError.jsp page. If we want to include the JSF tags in systemError.jsp page, the request should pass through FacesServlet, so in the <error-page> <location> tag systemError page is specified with the extention systemError.jsf though it's actual extention is .jsp
    When exception is thrown from the application container invoke the error page but, while rendering systemError.jsf page exception is thrown saying "Exception processing error page "systemError.jsp" "
    To solve this problem i've gone through several forums, materials.
    In one forum a guy said, JSF1.1 spec has some problem in displaying error pages. To solve this don't write <f:view> tags in the error page, use <f:subview> intstead. By reading this, i again changed the contents of systemError.jsp page replacing <f:view> by <f:subview>. But the error is still repeating.
    Finally what i found is, when we use Ajax4jsf in the application, its AjaxViewRender class is throwing exception while rendering error pages configured through web.xml.
    So what i did is i changed error page extention from .jsf to .jsp in the <location> tag. Now jsf won't come in the picture and remove JSF related tags from the systemError.jsp page.
    <error-page>
    <exception-type>java.lang.Throwable</exception-type>
    <location>/rc/systemError.jsp</location>
    </error-page>
    Any comments are welcome----------------------------------------------------------------

    I too iam facing the same problem could you advise if you have found any solutions
              -Ram

  • Handle exception on server side and display a customized jsp error page

    Hi,
    I am developing a java/j2EE web application using servlet, jsp, ejb3 with JBOSS and ECLIPSE.
    Two cases can occur on the server side :
    1) either I have not an expected result in a method and in this case I want to display an error page (a JSP page I suppose) with a personnalized error message
    2) or I have an exception thrown and I want to display the exception message in the former JSP page
    I don't know how to cope with this problem of personnalized error message (or the message of a thrown exception) with a JSP page.
    Does anybody can help me ? Thank you
    Edited by: xflamant on Jun 20, 2009 10:51 AM

    For the case of an unknown Error, simply use a default error page.
    The redirection to this page can be accomplished by inserting folowing code into your web.xml:
         <error-page>
            <exception-type>java.lang.Throwable</exception-type>
            <location>/WEB-INF/jsp/error.jsp</location>       
        </error-page>Known exception can be caught via a try-catch block.
    Then simply dispatch to the page you want displayed an add an attribute containing the error message to the response object.
    This attribute can then be used in the target page to diplay the error.

  • Why jsp throw exception , but error page can' t catch it .

     

    I use japanese Unix.
              so must add follow
              <%@ page contentType="text/html;charset=SJIS" %>
              then error happen
              Jim Clark wrote:
              > I'm not sure what the problem is, but the following works for me in WL5.1
              > SP3 on NT:
              >
              > <%@ page errorPage="testerror.jsp" %>
              > <h1>hello</h1>
              > <%
              > String yes = "yes";
              > if ( yes.equals("yes")) throw new IllegalStateException("yes");
              > %>
              >
              > The page that shows is my testerror.jsp. Double check your page directive
              > specifying your error page.
              >
              > --
              > Jim Clark
              > Idea Integration
              > http://www.idea.com
              >
              > "yang" <[email protected]> wrote in message news:[email protected]...
              > > I use error page , but jsp have exception . error page not catch it.
              > >
              > > throw follow exception only
              > >
              > > ? 6 19 19:01:03 JST 2000:<E> <ServletContext-General> Servlet failed
              > > with Exception
              > >
              > > java.lang.IllegalStateException: Attempt to change ContentType after
              > > calling getWriter() (cannot cha
              > > nge charset from 'SJIS' to 'null')
              > > at java.lang.Throwable.fillInStackTrace(Native Method)
              > > at java.lang.Throwable.fillInStackTrace(Compiled Code)
              > > at java.lang.Throwable.<init>(Compiled Code)
              > > at java.lang.Exception.<init>(Compiled Code)
              > > at java.lang.RuntimeException.<init>(Compiled Code)
              > > at java.lang.IllegalStateException.<init>(Compiled Code)
              > > at
              > > weblogic.servlet.internal.ServletResponseImpl.setEncoding(Compiled Code)
              > >
              > > at
              > > weblogic.servlet.internal.ServletResponseImpl.setContentType(Compiled
              > > Code)
              > > at
              > > weblogic.servlet.internal.ServletStubImpl.invokeServlet(Compiled Code)
              > > at
              > > weblogic.servlet.internal.RequestDispatcherImpl.forward(Compiled Code)
              > > at weblogic.servlet.jsp.PageContextImpl.forward(Compiled Code)
              > > at
              > > jsp_servlet._aeonmarket._loan._W_95_AEL032._jspService(Compiled Code)
              > > at weblogic.servlet.jsp.JspBase.service(Compiled Code)
              > > at
              > > weblogic.servlet.internal.ServletStubImpl.invokeServlet(Compiled Code)
              > > at
              > > weblogic.servlet.internal.ServletContextImpl.invokeServlet(Compiled
              > > Code)
              > > at
              > > weblogic.servlet.internal.ServletContextImpl.invokeServlet(Compiled
              > > Code)
              > > at
              > > weblogic.servlet.internal.ServletContextManager.invokeServlet(Compiled
              > > Code)
              > > at weblogic.socket.MuxableSocketHTTP.invokeServlet(Compiled
              > > Code)
              > > at weblogic.socket.MuxableSocketHTTP.execute(Compiled Code)
              > > at weblogic.kernel.ExecuteThread.run(Compiled Code)
              > >
              

  • I have an iphone 4.  Recently I cannot receive pictures or receive normal texts. All my texts come in as ichat messages.  Even if it's from another iphone.  I've reset and followed the support page instructions... still having problems. Thanks!

    I have an iphone 4.  Recently I have been unable to receive pictures or normal texts.  All texts come in as ichat messages.  The phone is slow and it takes a while to get the messages.  I've reset the phone and followed the steps on the support page.  Still having problems!  Any suggestions??
    Thanks!

    Hi,
    I also have a similar issue since upgrading from the 4s to the 5s.
    The issue I have is, issue number 2:" If I do receive a text message/iMessage notification, it disappears within 5-10 minutes before I can even check (no other notifications disappear)"
    Which also consists of the same events in the last message from monicash "So for example, if i get a text while sleeping... i wake up in the morning to check my notifications and there is nothing there because it disappeared (even though there should be a notification there with my current settings that are ON)."

  • JSP default error page - not sure where this goes

    So I am not sure where the jsp section of the forums is but Ill post here ....
    Any ways I dont like the look and feel of the current default error page when you throw an error on a jsp so i created my own cutom error page and set that as isErrorPage="true" then in the header.jsp I placed errorPage="error.jsp."
    It doesnt work.
    I have a jsp, a servlet and the error page. the jsp sends information to the servlet which sends the result back. if that servlet throws an error then it should be displayed on the error.jsp page where I told it to...How ever - it just goes to the default error page.
    How do I fix this.
    Sorry if this doesn't belong here not sure where else to put it. and in theory - it is java.

    user8974754 wrote:
    Yes its shown in the jSP. so how do I make the servlet be like "oh...thats the error page I want to display the error on"I'm pretty sure you can't, since it's a JSP mechanism, not a Servlet mechanism.
    And even if it was possible, it's not something that could be recommended.
    A normal way would be to catch the exceptions in your servlet and handle them there (log the exception and redirect to an error page).

  • Error page, catching Exception

    Hello.
    When my page throws Exception, i redirect it to error page.
    I have this code in web.xml:
       <error-page>
          <exception-type>java.lang.Exception</exception-type>
          <location>/error.jsp</location>
       </error-page>      Everything is ok.
    But i want to write this exception to my log. I want do this in error page.
    So my question is:
    how can I get this exception on error page?

    Jsp' directive in /error.jsp
    <%@page isErrorPage="true" %>
    then variable "exeption" is availible in jsp, like this
    <%
    StackTraceElement[] st = exception.getStackTrace();
    %>

  • Customize error-page

    Hi all,
    May I customize error page for HTTP Status 401 (http authentication error)? I am using <auth-method>BASIC</auth-method> , therefore
    <form-error-page>/xxx.jsp</form-error-page> is not working, please advise.
    Thx.
    Jacky

    Use <error-page>/error.html</error-page> element

  • Having Problem on using WRT 600 N Storage.

    Hello everyone:
    I'm using the WRT600N Wireless, and decided to use the Storage today.
    But after I setup the harddrive( connection is ok, and I can see the harddrive on the 192.168.1.1 page), I'm having problem on " how to connect to the harddrive by using my computer"?
    Is there any ip address which I can use for connecting?
    and I also setup the Media Server, and I can see the server by using my PS3, but I cannot see any files inside(I already copy some different types of movies inside).
    Please help me. thanks! 

    In order for it to work, you have to plug in a new hard drive with no data on it and format it using LELA.  I found that I will avoid the USB "feature" and stick with my shared drive.  It's 500% faster and I can take my hard drive anywhere without worrying I can't use it later with the router. 

  • Problem in Jsp Error page mechanism

    Hi every body,
    In my Jsp application I do some processing within scriplet tags. I have defined a error page using a page directive and I have defined my Error page separately. When there is an exception in a Jsp page, some times it calls the error page properly and displays it. But curiously in some occasions when there is an exception it doesn't call the error page, instead it includes the content of the Error page at the end of the same page, where the exception occurred. The web server is jakarta-tomcat-3.2.1. Can any one who has a idea about this problem help me. Your help is greatly appreciated.
    Thank you

    Hi there!
    Well I was having the same problem as yours until I realized what was going on: the jsp writer has a small buffer size (by default 8kb) and that is why it flushes some html before displaying the error page. The jsp writer buffer is full before getting the exception, so it flushes the buffer and keeps on writing until the exception is thrown. Then the jsp writer writes the error page code...
    You have to add some new parameters in your page directive: autoFlush(true or false) and buffer="16kb" (as much kbytes as you want). For example,
    <%@page autoFlush="false" buffer="sizekb".... %>
    If autoFlush="false", the jsp writer has not finished and the buffer is full an exception will be thrown.
    If autoFlush="true" and the buffer is full it will flush the buffer and so on.
    In both cases, if the buffer size is big enough the error jsp page will be the only displayed
    Good luck!
    Inaki

  • I'm having problems with 8.1 and Continuity / Handoff. It will work fine for web pages, etc. but in email when I try to do it between by iPhone 5s running 8.1 and my Macbook Pro running Yosemite I consistently get an error.

    I'm having problems with 8.1 and Continuity / Handoff. It will work fine for web pages, etc. but in email when I try to do it between by iPhone 5s running 8.1 and my Macbook Pro running Yosemite I consistently get an error. "Failed to Continue Activity" Cocoa Error 4609.  Handoff is working for phone calls and text messages. By email just crashes each time. It was also doing it under 8.0.2.  My iPhone and iPad handle this fine. It's only the MacBook to the iPhone that fails, and only on email.

    Handoff Continuity Troubleshooting

  • Latest version of Firefox is having problems loading sites, it tries to load to Google Analytics. No error messages, just a page that won't load. How do I stop this?

    Latest version of Firefox is having problems loading some sites, it tries to load and then gets taken over trying to load Google Analytics. No error messages, just a page that won't load. How do I get rid of this, it is a "pain in the neck"
    == URL of affected sites ==
    http://

    I just spent 3 days with this issue as well. I finally fixed it by reluctantly adding yet another add-on called ADBLOCK
    I was able to selectively block google-analytics. Now pages that weren't loading before are now loading.
    eg vimeo.com starbucks.com & other random sites.
    This was a tough one to fix because there is NO ERROR MESSAGE..page just shows it's loading...forever..& the bottom of my browser says 'waiting for google analytics'. I finally figured out google analytics is the culprit. Ironically, some help pages in trying to find a fix wouldn't load for me due to google analytics arghhh!
    Im on a macbookpro & Safari worked fine for these same sites. It was just Firefox. I nearly switched back to Safari because of this stupid issue.
    I'm wondering if this was caused by recent firefox 'updates'...

  • Problems with jsp-error page in web.xml

    Hello everybody, I have a confusing problem concerning the use of jsps as error pages for 404-errors.
    I inserted the following lines in my web.xml file:
    <error-page>
    <error-code>404</error-code>
    <location>/personal404.jsp</location>
    </error-page>
    The problem is: when an 404 occurs, instead of showin the personal404.jsp, the browser tells me that it tries to download a file which it can't (it tries to download the mis-spelled file). When I try to redirect the 404 to a static html-page, as in
    <error-page>
    <error-code>404</error-code>
    <location>/personal404.html</location>
    </error-page>
    everything works fine.
    Please, does anybody have any idea or suggestion, what I am doing wrong?
    Thanks in advance,
    Sebastian

    Hi Ivan,
    I tried it, but there wasn't any difference.
    I'll try to explain in more detail what happens:
    Imagine my application has the following root-path
    http://myServerName:port/mainRoot/
    When I try the following URL:
    http://myServerName:port/mainRoot/pageThatDoesNotExist.jsp, the browser tells me, it tries to download the file pageThatDoesNotExist.jsp from myServerName and that it can't find that file.
    The same happens, when I type http://myServerName:port/mainRoot/pathThatDoesNotExist/pageThatDOESExist.jsp, except that the browser tries to download the file pageThatDOESExist.jsp which (again) it can't.
    I have located the files 404.jsp and 404.html in the same directory, so I don't think this is a path-related problem, because everything works fine, when I specify the 404.html as the target error page (i.e. the browser displays the 404.html when I type the URLs shown above).
    I don't know if I'm making this clear, but maybe you get the idea.
    Sebastian

Maybe you are looking for

  • Short dump while executing report group.

    Hi, We are upgrading to ECC6.0 from 4.6C Now while testing the report group i got short dump. This is due to to the 'Exception condition "LOAD_PROBLEMS" raised.' Error analysis     A RAISE statement in the program "SAPLSLDB" raised the exception    

  • Most of my songs wont upload onto my itunes

    i got a new laptop so i was transferring my music from my old computer to this laptop. all of the files transferred fine....but when i try to upload the songs, only 120 something songs out of 400 come up. and so i tried uploading them one by one and

  • 23.976 video problems

    Using Encore 2. I have some TV episodes (AVI) that are 23.976 pps and fps. Last time I imported them and 4 episodes took 12 hours, but all was okay. I figured this time I would process using AVISynth with a pulldown, and it produced the .m2v with 23.

  • Add fields to Standard Purchase Order

    How can I change the standard order data definition. I need to add some fields that are not in the standard po definition. Must i add fields to po_headers_xml. But i think I also have to change the .xsd file. But how can I change them ?

  • U3415W, randomly goes black for like 2 seconds?

    Just got this monitor and I'm having the exact same issue. Goes black for like 2 seconds randomly. It's differently on the monitor side of things, as I have another monitor connect through DP(daisy chain) and the same issue happens on that monitor as