Results 1 to 7 of 7
- 07-15-2010, 12:15 PM #1
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
Java Code:<%@ 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
web.xmlJava Code:<%@ 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>
Please see if you can help…Java Code:<?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>
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... :confused:
Goldest
- 07-15-2010, 01:49 PM #2
Member
- Join Date
- Jun 2010
- Location
- Bangalore,India
- Posts
- 70
- Rep Power
- 0
make sure both throwError.jsp and your errorPage.jsp are in the same folder.If not give the correct path in the JSP.
No entry is needed in the web.xml
just make sure the path of the image your placing in the errorPage.jsp
Otherthings should work fine...
:)Arun K R,Bangalore,India
:)
- 07-15-2010, 03:12 PM #3
Yes.
Hi Arun,
Thanks for the response. Everything is in place... Attaching a snapshot of eclipse structure here as well.
The settings in web.xml are just to make sure that someway or the other, the error image will get displayed [either by an exception or through error code].
Please see if you can have this configured at your eclipse if time permits. That would give you a better idea.
Thanks in advance!
Goldest
- 07-16-2010, 10:29 AM #4
Member
- Join Date
- Jun 2010
- Location
- Bangalore,India
- Posts
- 70
- Rep Power
- 0
Dont put the code in the declarative tag.
Put it in the scriplet tag
Instead of
<%! int x = 12/0; %>
put
<%
int x = 12/0;
%>Arun K R,Bangalore,India
:)
- 07-16-2010, 03:19 PM #5
No Success...
Hey Arun,
Tried your suggestion, but still no success. The same error gets displayed : HTTP 500 Internal Server Error.
Any other trick to try out?
Thanks for the response,
Goldest
- 07-19-2010, 07:21 AM #6
Member
- Join Date
- Jun 2010
- Location
- Bangalore,India
- Posts
- 70
- Rep Power
- 0
Its working fine for me..
Just you try to run the program in Mozilla .. it will show the exact error.
You post the error.. Hope i can help after seeing the error..Arun K R,Bangalore,India
:)
- 07-19-2010, 08:35 AM #7
Ohh yeah
Now, this is weird. But I don't know how can this happen? Even I can see the correct output in Mozilla. I am currently using the Eclipse Ganymede. This version gives 4 options of browsers to use.
- Internal Web Browser
- Default System Web Browser
- Internet Explorer
- Mozilla
Majority of the times I select "Default system web browser" and it works fine for almost all the applications. This time I don't know what has changed. No other browser options than Mozilla are working for this particular application. The rest of the applications works fine with other browser options as well.
Thanks Arun, it works in Mozilla. And the error message is the same with other browser options:- "The webpage can't be displayed. HTTP 500 Internal Server Error."
Anyone having any idea about such weird behavior? Or Any particular setting that I need to do?
Thanks much,
GoldestLast edited by goldest; 07-19-2010 at 08:36 AM. Reason: Change
Similar Threads
-
Error while parsing html page in java on linux
By rdhaware in forum Advanced JavaReplies: 1Last Post: 02-20-2009, 02:20 AM -
How can i create an error page in jsp and invoke it ...?
By vrk in forum Java ServletReplies: 0Last Post: 02-16-2009, 08:05 AM -
Common error page using struts tiles...?
By prabhurangan in forum Web FrameworksReplies: 0Last Post: 08-28-2008, 02:34 PM -
problems with my JSP login page
By ilangocal in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 04-28-2008, 06:40 PM -
problems when I try to execute a jsp page
By christina in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 08-01-2007, 12:23 PM


LinkBack URL
About LinkBacks

Bookmarks