Hi Kevin,
        i have done exactly what you are saying:
- JSP using Model 2 architecture
- the JSPs are written in XML using a JSP Custom Tag



> Hi all,
>
> I am interested in using XSL for UI purposes of web pages. I
> am reading a
> bit about it, and have a decent understanding of its purpose, but I am
> wondering if anyone doing this can give me a little insight into the
> process.
>
> Currently, we are using a MVC framework: single controller
> servlet, one or
> more action classes, jsp pages, javabeans, etc. Some JSP
> pages use looping
> constructs to display a list of items. All have some sort of
> HTML in them.
>
> So, I ask..is what I am about to list the "right" way of
> moving away from
> MVC forwarding to JSP pages, but instead using JSP to return
> XML that is
> then applied with an XSL file to convert to HTML then return
> that HTML the
> right way.
>
> 1) request goes to action class (through the controller servlet)
ok
> 2) action class calls back-end logic (ejb) which populates a
> javabean with
> results.
ok
> 3) JSP page is read in via URLConnection (or something similar) which
> returns XML content (not HTML).

in my case, i am doing EXACTLY the same as Model 2 architecture, using
request.sendRedirect or RequestDispatcher.forward()

the JSP file includes an XML file, via the use of a JSP custom tag

in the implementation of the tag itself (that YOU have to write), you fetch
the content of your custom tag (actually, the content is plain XML); then,
you instantiate an XSLT processor, and you call the process() method by
giving as parameter:
- JspWriter
- the XML content of your tag
- the XSL stylesheet, that you can fetch from the Session or make it as an
attribute of your custom tag



> 4) The JSP page doesn't include any HTML, but instead XML
> tags and uses the
> javabean to insert the data that fits in those tags
exactly

> 5) XALAN is then somehow called with the resulting XML
> (probably in a String
> or StringBuffer), a XSL file path/name is also passed in, and
> either it
> returns
> a String (or StringBuffer) of the transformed HTML, or you pass in a
> StringBuffer that then gets populated with the transformed HTML.
> 6) Place the HTML output from XALN in the response buffer.
> 7) return the response.

as i explained you above, in the implementation of your JSP Custom Tag you
do like this:

BodyContent body = getBodyContent();
String content = body.getString();
try {
     JspWriter out = body.getEnclosingWriter();
     XSLTProcessor.process(out, content,xsl);
    }  catch(SAXException exc) {
     System.err.println("There was a SAX Exception! " );
     exc.printStackTrace();
    }

In the above example, xsl is the xsl stylesheet that you either put in the
Session, or as an attribute of your Custom Tag

>
> In this manner, if this is correct, each and every request
> would require the
> use of a URLConnection, reading in the xml output from the
> JSP page that is
> build dynamically via the javabean results the JSP page makes
> use of. It
> then gets transformed into HTML by XALAN using an XSL of some
> sort, and the
> result..instead of RequestDispather forwarding or
> response.sendRedirect() to
> a JSP page, gets put in the respone buffer (much like doing
> HTML the old way
> in servlets) and that goes back.

no......the Action classes are still using response.sendRedirect or
RequestDispatcher.forward

>
> Is this the way its done? Or is there some other way? I am
> sure there are
> lots of ways, but I am hoping to use the most common approach that
> developers are using today.
>
> I have a bit to learn, but in general..is it common to use
> XSL in place of
> JSP for HTML output if you are going to go this route? Should
> I rework all
> my JSP pages into returning XML, remove HTML out of them, put
> XML tags in
> them and only data in those tags (from the javabean for that
> page that the
> controller/action populates via the logic), then apply XSL to
> "format" the
> data of the XML?

YES

> My original knowledge led me to believe I
> leave my JSP
> pages as they are and apply formatting via XSL..but I don't
> think that can
> work.



>
> Lastly, I would like to look into the use of XSL for
> producing PDF, RTF, and
> WML. WML would be for wireless devices. PDF can be converted
> to PostScript

you just have to change the stylesheet to apply


> by our faxing solution, and RTF can be displayed with better than HTML
> formatting (as could PDF) on screen, ofcourse requiring an
> RTF plugin to a
> browser (which MSIE doesn't require for Windows platforms).
> We are using a
> hokey document producing factory, where by we require two
> classes (on for
> reading and one for writing the xml) as well as a new class
> to "lay out" the
> output of the document. I would think this could be abolished
> by simply
> creating an XSL that produces the RTF out of the data from
> the xml. Is this
> so?
>
> Thank you very much.
>
> ==============================================================
> =============
> To unsubscribe: mailto [EMAIL PROTECTED] with body:
> "signoff JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set
> JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to