0

Problems wih jsp dynamicallycreating zul pag

asked 2007-04-13 09:53:00 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4258623

By: spromano

Hi all,

I'm trying to use the DhtmlLayout filter in order to dynamically produce zul pages (I'm doing this in order to enrich an existing web app...). I've been trying for the last two days to solve an issue with the SAX parser, which keeps on raising exceptions, e.g.:

1- with a simple jsp like the following:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<window title="My First window" border="normal" width="200px">
Hello, World!
</window>

...I get the following message:

org.zkoss.zk.ui.UiException: org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed

2- if I try to use a doctype declaration (see http://sourceforge.net/forum/message.php?msg_id=3797981), I have:

JSP:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE xhtml "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<window title="My First window" border="normal" width="200px">
Hello, World!
</window>

Exception:

org.zkoss.zk.ui.UiException: org.xml.sax.SAXParseException: The document type declaration for root element type "xhtml" must end with '>'.

I really don't know what to try more in order to address this issue. Any help is more than welcome.

Cheers,

Simon


delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2007-04-13 10:38:20 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4258690

By: spromano

Hi all,

I'm trying to use the DhtmlLayout filter in order to dynamically produce zul pages (I'm doing this in order to enrich an existing web app...). I've been trying for the last two days to solve an issue with the SAX parser, which keeps on raising exceptions, e.g.:

1- with a simple jsp like the following:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<window title="My First window" border="normal" width="200px"> Hello, World!
</window>

...I get the following message:

org.zkoss.zk.ui.UiException: org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed

2- if I try to use a doctype declaration (see http://sourceforge.net/forum/message.php?msg_id=3797981), I have:

JSP:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE xhtml "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<window title="My First window" border="normal" width="200px"> Hello, World!
</window>

Exception:

org.zkoss.zk.ui.UiException: org.xml.sax.SAXParseException: The document type declaration for root element type "xhtml" must end with '>'.

I really don't know what to try more in order to address this issue. Any help is more than welcome.

Cheers,

Simon



link publish delete flag offensive edit

answered 2007-04-14 01:29:14 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4260225

By: jumperchen

You need to define a namespace with "http://www.zkoss.org/2005/zul" ,and then use the following.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<x:window title="My First window" border="normal" width="200px"
xmlns:x="http://www.zkoss.org/2005/zul">
Hello, World!
</x:window>

please read the ZK- Small Talk : "Work with Legacy Web Applications, Part II
- JSP"

http://www.zkoss.org/smalltalks/legacy-jsp/legacy-jsp.html

Best Regards,
Jumper

link publish delete flag offensive edit

answered 2007-04-14 13:02:33 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4260652

By: spromano

Hi Jumper,

thank you for the reply. I tried with the zul namespace added (as you suggest), but nothing changes. Maybe the problem is in the fact that the output of the jsp MUST be a well-formed zhtml page rather than a well-formed zul page? Indeed, if I turn the filter off, the page produced is a well-formed zul page, even though it has a blank line at the beginning...if I save this page as page.zul and try to load it form the browser, everything is ok. If I save it as page.zhtml, firefox is able to load it correctly, whereas IE gets a bit confused.
Or is there something related to the java jre (I'm using jre 1.5.0_05)?

Thanks a lot for your feedback,

Simon

link publish delete flag offensive edit

answered 2007-04-14 22:01:50 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4261139

By: spromano

Hi again,

by now I solved the issue in the quickiest yet dirtiest way:

**********************************************************************
<%@ page language="java" contentType="text/html" pageEncoding="ISO-8859-1"
import="java.io.PrintWriter, java.io.FileOutputStream"%>

<%
try {
PrintWriter writer = new PrintWriter(new FileOutputStream("C:\\Programmi\\apache-tomcat-5.5.12\\webapps\\MyZkSamples\\jsp
\\DynamicZulFile.zul", false), true);
writer.println("<window title=\"My First window\" border=\"normal\"
width=\"200px\">");
writer.println("Hello, World!");
writer.println("</window>");
writer.flush();
writer.close();
}catch(Exception ex) {
ex.printStackTrace();
}
%>

<html>
<body>
<center>
<jsp:include page="DynamicZulFile.zul"/> </center> </body> </html>
********************************************************************************
***************************

I removed the filter and opted for the <jsp:include> tag...
After wasting two whole days, I'm getting convinced there's something wrong either in myself (;-)) or in the DhtmlLayoutFilter provided with ZK.
If someone has a "working" example I would really appreciate some "detailed"
info (tomcat version, jdk version, ZK version, whole web.xml file, plus a working jsp making use of the filter) about how the problem can be faced without getting crazy.

Thanks a lot in advance,

Simon

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: 2007-04-13 09:53:00 +0800

Seen: 576 times

Last updated: Apr 14 '07

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