0

jsp as error page

asked 2012-10-10 13:11:09 +0800

astoev gravatar image astoev
39

Hello,

I have issues with jsp error page. The jsp itself is very simple and works when accessed directly by URL. It is mapped in zk.xml as error-page, but in case of error I got the following :

SEVERE: Unable to generate custom error page, error.jsp
>>org.zkoss.lang.SystemException: org.xml.sax.SAXParseException: The markup in the document preceding the root element must be well-formed.

There are some more checks ZK does in addition to the servlet container. Does ZK support non-zul error pages? Ideas ?
ZK 6.0.2, Tomcat 6.0.29, Java 1.6.0.35


Aleksandar

delete flag offensive retag edit

7 Replies

Sort by ยป oldest newest

answered 2012-10-18 04:47:09 +0800

samchuang gravatar image samchuang
4084 4

hi, can you post your sample code, the one got this exception ?

link publish delete flag offensive edit

answered 2012-10-18 08:17:45 +0800

astoev gravatar image astoev
39

Hello,

Hello,

here you are -

zk.xml :

<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>error.jsp</location>
</error-page>


error.jsp :

<%@page import="org.slf4j.Logger,org.slf4j.LoggerFactory;" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>...</title>
<link href="<%=request.getContextPath()%>/assets/style/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
...some pretty page here ...
</body>
</html>
<% Logger logger = LoggerFactory.getLogger("UI errors");
logger.error("error message", request.getAttribute("javax.servlet.error.exception")); %>

Once again, the page is valid and is rendered when accessed directly, but fails when for example Composer or .zul throws an exception with the above error.
Thank you in advance!

Aleksandar

link publish delete flag offensive edit

answered 2012-10-19 03:31:51 +0800

samchuang gravatar image samchuang
4084 4

Hi, refer to the Error Handling

put setting to web.xml

for example, in web.xml

	<error-page>
		<exception-type>java.lang.Throwable</exception-type>
		<location>/WEB-INF/error.jsp</location>
	</error-page>

and the error.jsp file works file

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
Error test
</body>
</html>

link publish delete flag offensive edit

answered 2012-10-19 15:30:30 +0800

Steva77 gravatar image Steva77 flag of Italy
1014 3
http://www.research.softe...

I.e. astoev, you should use the web.xml file and not the zk.xml file ;)

link publish delete flag offensive edit

answered 2012-10-31 15:12:29 +0800

astoev gravatar image astoev
39

Hello there,

I have tested the code offered by samchuang. For some reason I got :

SEVERE: Unable to generate custom error page, /WEB-INF/error.jsp
>>org.zkoss.lang.SystemException: org.xml.sax.SAXParseException: The declaration
for the entity "HTML.Version" must end with '>'.
>>org.xml.sax.SAXParseException: The declaration for the entity "HTML.Version" m
ust end with '>'.

Steva77, thank you for your comment also, I have the error page declaration in both web.xml and zk.xml. If I omit the zk.xml it is just not processed.

Any other thoughts?

Thank you,
Aleksandar

link publish delete flag offensive edit

answered 2012-10-31 15:42:54 +0800

Steva77 gravatar image Steva77 flag of Italy
1014 3
http://www.research.softe...

Try to regenerate with the wizard a brand new default error.jsp... it might be copy&paste from here imported some bad character...

link publish delete flag offensive edit

answered 2012-11-01 08:32:32 +0800

astoev gravatar image astoev
39

Hello Steva77,

I also think the problem might be some strange character. I created new jsp page (again) with the Eclipse wizzard and the result is the same : SAXParseException: The markup in the document preceding the root element must be well-formed.

What else could it be?

Best Regards,
Aleksandar

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-10-10 13:11:09 +0800

Seen: 147 times

Last updated: Nov 01 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More