Meaningless Drivel is fun!*
The moose likes JSP and the fly likes How to dynamically convert XML to HTML using JSP? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "How to dynamically convert XML to HTML using JSP?" Watch "How to dynamically convert XML to HTML using JSP?" New topic
Author

How to dynamically convert XML to HTML using JSP?

Faxin Zhao
Greenhorn

Joined: Jul 18, 2003
Posts: 16
Hi,
I have a problem.
I can search an account using a servlet and a jsp file,
and show the results using XML.
Now I need to minitor those output and show it using HTML.
I run the following jsp, but got error:
<%@taglib uri="http://jakarta.apache.org/taglibs/xsl-1.0" prefix="xslt" %>
<html>
<head>
<title>Account Monitor</title>
</head>
<body>
<center>
Minitor
<p></p>
<xslt:apply xml="http://localhost/servlet/acctMonitor?acctKey=1234678&branch=BIC" xsl="bic.xsl"/>
</center>
</body>
</html>

What's wrong?
Thanks in advance.

Exception in jsp:
org.apache.jasper.JasperException: Could not locate TLD META-INF/taglib.tld at
org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:217) at
org.apache.jasper.compiler.JspParseEventListener.handleDirective(JspParseEventListener.java:648) at
org.apache.jasper.compiler.DelegatingListener.handleDirective(DelegatingListener.java:110) at
org.apache.jasper.compiler.Parser$Directive.accept(Parser.java:194) at
org.apache.jasper.compiler.Parser.parse(Parser.java:984) at
org.apache.jasper.compiler.Parser.parse(Parser.java:959) at
org.apache.jasper.compiler.Parser.parse(Parser.java:955) at
org.apache.jasper.compiler.Compiler.compile(Compiler.java:140) at
org.apache.jasper.runtime.JspLoader.loadJSP(JspLoader.java:226) at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:142) at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:153) at
org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:245) at
org.apache.jasper.runtime.JspServlet.service(JspServlet.java:350) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:868) at
com.gefionsoftware.server.ServletContextImpl$ServletHandler.call(ServletContextImpl.java) at
com.gefionsoftware.server.ServletContextImpl.executeServlet(ServletContextImpl.java) at
com.gefionsoftware.server.ServletContextImpl.execute(ServletContextImpl.java) at
com.gefionsoftware.server.GenericServer.execute(GenericServer.java) at
com.gefionsoftware.server.lws.LiteWebServer$RequestHandler.run(LiteWebServer.java) at
se.pureit.util.ThreadPool$WorkThread.startRunnable(ThreadPool.java) at
se.pureit.util.ThreadPool$WorkThread.run(ThreadPool.java)
Simon Harvey
Ranch Hand

Joined: Jan 26, 2003
Posts: 79
Hi,
I've been doing this sort of stuff recently and because its pretty hard and there is a lot that can go wrong, I made a really simple standalone app so that I can be sure that i have the code correct, but also so that i can check the xslt is valid and see the output. The whole thing is less than 40 lines of cose - TOPS
Its essentially a tactic i use all the time - seperate the various parts and test them ina very simple and isolated environment to identify the problem.
If you would find that code helpful, just let me know and I'll post it here for you

Simon
Faxin Zhao
Greenhorn

Joined: Jul 18, 2003
Posts: 16
Hi Simon,
Thanks for your reply.
Yes, please post your code here.
Faxin Zhao
Greenhorn

Joined: Jul 18, 2003
Posts: 16
Anybody can help me?
Simon Harvey
Ranch Hand

Joined: Jan 26, 2003
Posts: 79
Hi there my friend,
I am really really sorry. I forgot about your post because i couldnt see it. I only just noticed it again. I deleted my actual source code for what you are looking for but I found the following for you. It demonstrates just how EASY it is to do a transform. What I suggest, is that you make a really simple standalone application that takes two parameters, the file names of the xml and xsl documents and then outputs the result to a text file.
Alternatively, you could ammend the jsp page that I am posting here and have the html displayed in the browser. That would be the better but slightly harder option. You would get to see if your html is valid though
I really hope this helps.Sorry no-one else replied. Remember though, there is a specific xml/xsl forum and this question was only loosely related to jsp.
Simon
Simon Harvey
Ranch Hand

Joined: Jan 26, 2003
Posts: 79
Sorry, I should have added that the above code was taken from the Wrox book Beginning Java Databases (Chapter 21)
Thanks
Simon
 
jQuery in Action, 2nd edition
 
subject: How to dynamically convert XML to HTML using JSP?