wood burning stoves 2.0*
The moose likes JSP and the fly likes Problems with jsp-error page in web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Problems with jsp-error page in web.xml" Watch "Problems with jsp-error page in web.xml" New topic
Author

Problems with jsp-error page in web.xml

Sebastian Hinz
Greenhorn

Joined: Nov 06, 2002
Posts: 5
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>/404.jsp</location>
</error-page>
The problem is: when an 404 occurs, instead of showin the 404.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>/404.html</location>
</error-page>
everything works fine.
Please, does anybody have any idea or suggestion, what I am doing wrong?
Thanks in advance,
Sebastian
Sandeep. Oza
Ranch Hand

Joined: Feb 04, 2002
Posts: 66
Originally posted by Sebastian Hinz:
the browser tells me that it tries to download a file which it can't (it tries to download the mis-spelled file).

Dear Sebastian,
explain in detail... meaning of above quote..
Don't get your problem clearly.. May be your path to this jsp file will be wrong or check settings/options of your browser..
Good Day.
Sandeep Oza


Yes, Everything Is Possible
Sebastian Hinz
Greenhorn

Joined: Nov 06, 2002
Posts: 5
Hi Sandeep,
I'll try to explain 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.
Good day for you,
Sebastian
[ November 07, 2002: Message edited by: Sebastian Hinz ]
Sandeep. Oza
Ranch Hand

Joined: Feb 04, 2002
Posts: 66
You are right Sebastian.
Will you pl. try by changing name of jsp file..?
clear your work folder( in tomcat), shutdown and restart server.
Also check.. by typing: [URL=http://myServerNamehttp://myServerName ort/mainRoot/ [/URL] and enter... It should show directory file structure with your jsp and html files...
Sandeep Oza
[ November 07, 2002: Message edited by: Sandeep. Oza ]
[ November 07, 2002: Message edited by: Sandeep. Oza ]
Sebastian Hinz
Greenhorn

Joined: Nov 06, 2002
Posts: 5
Dear Sandeep,
I renamed the file and the web.xml-entry to myError.jsp but the same thing happened. When I type the pure URL to see the directory structure (after removing the welcome file-list from web.xml), I can see both error pages (html and jsp)in the directory listing.
I really don't know, what point I am missing.
Sebastian
[ November 07, 2002: Message edited by: Sebastian Hinz ]
Sandeep. Oza
Ranch Hand

Joined: Feb 04, 2002
Posts: 66
Dear I also don't get...
Try... click on jsp file in your directory structure... will it opens?
I have doubt about slash("/") in your web.xml file.. it will take it as Escape character... replace it with double slash ("//")...
In JSP try on using..
<%@ page errorPage="/Myerror.jsp"%>
This is JSP error page redirect tag.
Sandeep Oza
[ November 07, 2002: Message edited by: Sandeep. Oza ]
Sebastian Hinz
Greenhorn

Joined: Nov 06, 2002
Posts: 5
Dear Sandeep,
guess what: I figured it out. This seems so strage to me. I don't know exactly what hit me, but I inserted the following lines in my web.xml.
<mime-mapping>
<extension>jsp</extension>
<mime-type>text/plain</mime-type>
</mime-mapping>
Now it does work. I don't know why the normal jsps worked without this mapping, but who cares anymore.
Thanks for your patience and your encouraging posts. Maybe we'll meet again someday.
Bye,
Sebastian
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems with jsp-error page in web.xml