You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matt Raible <ma...@yahoo.com> on 2002/01/19 19:14:21 UTC

Design Help Needed - Routing to common transformer JSP

I've figured out a pretty slick (I think) way to use XSL have one page that
changes the look and feel of my entire application.  Basically, I put all my
XML JSP's in a "pages" directory - and all they really contain is title,
heading, and form elements (populated by bean:write and html:form).  All
"layout" is controlled by a CSS stylesheet (I'm only supporting
standards-compliant browsers - and client agrees ;).  

So my "rough" solution at this point is to route all requests for JSP's to a
JSP (with the same name in the / directory).  So I have a JSP Transformer for
each JSP XML page.  I'd like to just have one page that does the
transformation.

However, there's GOT to be an easier way.  You would think it would be easy to
create a URL-mapping for this - or something like that.  I would like it would
be easy to create a <url-pattern> of *.jsx that would route to a
htmlTransform.jsp page.  Is this the best way?  I really like the idea of using
JSP's to get messages and form values - seems pretty easy.  If there is a way
of using a servlet in place of the htmlTransform.jsp - that might be a good
idea...

Thanks,

Matt


web.xml ---------
	<!-- XSLT Tranformer -->
	<servlet>
		<servlet-name>xslt</servlet-name>
		<jsp-file>/htmlTransform.jsp</jsp-file>
	</servlet>
	<!-- XSLT Mapping -->
	<servlet-mapping>
		<servlet-name>xslt</servlet-name>
		<url-pattern>*.jsx</url-patter>
	</servlet-mapping>

htmlTransform.jsp ----------------------

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/x.tld" prefix="x" %>

<% 
String xmlJsp = request.getServletPath(); 
xmlJsp = "/pages" + xmlJsp.substring(0,xmlJsp.indexOf(".")) + ".jsp";
System.out.println("xmlJsp = " + xmlJsp);

%>

<c:import url="<%=xmlJsp%>" var="xml"/> 
<c:import url="/styles/xsl-xhtml.jsp" var="xslt"/>
<x:transform source="$xml" xslt="$xslt"/>

__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Design Help Needed - Routing to common transformer JSP

Posted by Matt Raible <ma...@yahoo.com>.
Hmmm, you would think the code below would work - since I AM getting
"/pages/index.jsp" as a value - but I get the following error:

java.lang.IllegalArgumentException: Cannot URL decode request path /<%=xmlJsp%>



--- Matt Raible <ma...@yahoo.com> wrote:
> I've figured out a pretty slick (I think) way to use XSL have one page that
> changes the look and feel of my entire application.  Basically, I put all my
> XML JSP's in a "pages" directory - and all they really contain is title,
> heading, and form elements (populated by bean:write and html:form).  All
> "layout" is controlled by a CSS stylesheet (I'm only supporting
> standards-compliant browsers - and client agrees ;).  
> 
> So my "rough" solution at this point is to route all requests for JSP's to a
> JSP (with the same name in the / directory).  So I have a JSP Transformer for
> each JSP XML page.  I'd like to just have one page that does the
> transformation.
> 
> However, there's GOT to be an easier way.  You would think it would be easy
> to
> create a URL-mapping for this - or something like that.  I would like it
> would
> be easy to create a <url-pattern> of *.jsx that would route to a
> htmlTransform.jsp page.  Is this the best way?  I really like the idea of
> using
> JSP's to get messages and form values - seems pretty easy.  If there is a way
> of using a servlet in place of the htmlTransform.jsp - that might be a good
> idea...
> 
> Thanks,
> 
> Matt
> 
> 
> web.xml ---------
> 	<!-- XSLT Tranformer -->
> 	<servlet>
> 		<servlet-name>xslt</servlet-name>
> 		<jsp-file>/htmlTransform.jsp</jsp-file>
> 	</servlet>
> 	<!-- XSLT Mapping -->
> 	<servlet-mapping>
> 		<servlet-name>xslt</servlet-name>
> 		<url-pattern>*.jsx</url-patter>
> 	</servlet-mapping>
> 
> htmlTransform.jsp ----------------------
> 
> <%@ page language="java" %>
> <%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
> <%@ taglib uri="/WEB-INF/x.tld" prefix="x" %>
> 
> <% 
> String xmlJsp = request.getServletPath(); 
> xmlJsp = "/pages" + xmlJsp.substring(0,xmlJsp.indexOf(".")) + ".jsp";
> System.out.println("xmlJsp = " + xmlJsp);
> 
> %>
> 
> <c:import url="<%=xmlJsp%>" var="xml"/> 
> <c:import url="/styles/xsl-xhtml.jsp" var="xslt"/>
> <x:transform source="$xml" xslt="$xslt"/>
> 
> __________________________________________________
> Do You Yahoo!?
> Send FREE video emails in Yahoo! Mail!
> http://promo.yahoo.com/videomail/
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Routing to common transformer JSP - Solution w/ Bug

Posted by Matt Raible <ma...@yahoo.com>.
I found the following code to work, ugly as it it.  However, the bug I'm
experiencing now is that the page loads (and transforms) but the "loading"
progress bar at the bottom of the page continues for a good 30 seconds after
the page loads (both in IE and Netscape 6).  Any ideas?

<% 
String xmlJsp = request.getServletPath(); 
xmlJsp = "/pages" + xmlJsp.substring(0,xmlJsp.indexOf(".")) + ".jsp";
%>

<c:set var="xmlPath" scope="page">
	<%=xmlJsp%>
</c:set>

<c:import url="$xmlPath" var="xml"/> 
<c:import url="/styles/xsl-xhtml.jsp" var="xslt"/>
<x:transform source="$xml" xslt="$xslt"/>

--- Matt Raible <ma...@yahoo.com> wrote:
> Hmmm, doesn't work like I'd hoped:
> 
> java.lang.IllegalArgumentException: Cannot URL decode request path
> /<%=xmlJsp%>
> 
> 
> 
> --- Matt Raible <ma...@yahoo.com> wrote:
> > I've figured out a pretty slick (I think) way to use XSL have one page that
> > changes the look and feel of my entire application.  Basically, I put all
> my
> > XML JSP's in a "pages" directory - and all they really contain is title,
> > heading, and form elements (populated by bean:write and html:form).  All
> > "layout" is controlled by a CSS stylesheet (I'm only supporting
> > standards-compliant browsers - and client agrees ;).  
> > 
> > So my "rough" solution at this point is to route all requests for JSP's to
> a
> > JSP (with the same name in the / directory).  So I have a JSP Transformer
> for
> > each JSP XML page.  I'd like to just have one page that does the
> > transformation.
> > 
> > However, there's GOT to be an easier way.  You would think it would be easy
> > to
> > create a URL-mapping for this - or something like that.  I would like it
> > would
> > be easy to create a <url-pattern> of *.jsx that would route to a
> > htmlTransform.jsp page.  Is this the best way?  I really like the idea of
> > using
> > JSP's to get messages and form values - seems pretty easy.  If there is a
> way
> > of using a servlet in place of the htmlTransform.jsp - that might be a good
> > idea...
> > 
> > Thanks,
> > 
> > Matt
> > 
> > 
> > web.xml ---------
> > 	<!-- XSLT Tranformer -->
> > 	<servlet>
> > 		<servlet-name>xslt</servlet-name>
> > 		<jsp-file>/htmlTransform.jsp</jsp-file>
> > 	</servlet>
> > 	<!-- XSLT Mapping -->
> > 	<servlet-mapping>
> > 		<servlet-name>xslt</servlet-name>
> > 		<url-pattern>*.jsx</url-patter>
> > 	</servlet-mapping>
> > 
> > htmlTransform.jsp ----------------------
> > 
> > <%@ page language="java" %>
> > <%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
> > <%@ taglib uri="/WEB-INF/x.tld" prefix="x" %>
> > 
> > <% 
> > String xmlJsp = request.getServletPath(); 
> > xmlJsp = "/pages" + xmlJsp.substring(0,xmlJsp.indexOf(".")) + ".jsp";
> > System.out.println("xmlJsp = " + xmlJsp);
> > 
> > %>
> > 
> > <c:import url="<%=xmlJsp%>" var="xml"/> 
> > <c:import url="/styles/xsl-xhtml.jsp" var="xslt"/>
> > <x:transform source="$xml" xslt="$xslt"/>
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Send FREE video emails in Yahoo! Mail!
> > http://promo.yahoo.com/videomail/
> > 
> > --
> > To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Send FREE video emails in Yahoo! Mail!
> http://promo.yahoo.com/videomail/
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Design Help Needed - Routing to common transformer JSP

Posted by Matt Raible <ma...@yahoo.com>.
Hmmm, doesn't work like I'd hoped:

java.lang.IllegalArgumentException: Cannot URL decode request path /<%=xmlJsp%>



--- Matt Raible <ma...@yahoo.com> wrote:
> I've figured out a pretty slick (I think) way to use XSL have one page that
> changes the look and feel of my entire application.  Basically, I put all my
> XML JSP's in a "pages" directory - and all they really contain is title,
> heading, and form elements (populated by bean:write and html:form).  All
> "layout" is controlled by a CSS stylesheet (I'm only supporting
> standards-compliant browsers - and client agrees ;).  
> 
> So my "rough" solution at this point is to route all requests for JSP's to a
> JSP (with the same name in the / directory).  So I have a JSP Transformer for
> each JSP XML page.  I'd like to just have one page that does the
> transformation.
> 
> However, there's GOT to be an easier way.  You would think it would be easy
> to
> create a URL-mapping for this - or something like that.  I would like it
> would
> be easy to create a <url-pattern> of *.jsx that would route to a
> htmlTransform.jsp page.  Is this the best way?  I really like the idea of
> using
> JSP's to get messages and form values - seems pretty easy.  If there is a way
> of using a servlet in place of the htmlTransform.jsp - that might be a good
> idea...
> 
> Thanks,
> 
> Matt
> 
> 
> web.xml ---------
> 	<!-- XSLT Tranformer -->
> 	<servlet>
> 		<servlet-name>xslt</servlet-name>
> 		<jsp-file>/htmlTransform.jsp</jsp-file>
> 	</servlet>
> 	<!-- XSLT Mapping -->
> 	<servlet-mapping>
> 		<servlet-name>xslt</servlet-name>
> 		<url-pattern>*.jsx</url-patter>
> 	</servlet-mapping>
> 
> htmlTransform.jsp ----------------------
> 
> <%@ page language="java" %>
> <%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
> <%@ taglib uri="/WEB-INF/x.tld" prefix="x" %>
> 
> <% 
> String xmlJsp = request.getServletPath(); 
> xmlJsp = "/pages" + xmlJsp.substring(0,xmlJsp.indexOf(".")) + ".jsp";
> System.out.println("xmlJsp = " + xmlJsp);
> 
> %>
> 
> <c:import url="<%=xmlJsp%>" var="xml"/> 
> <c:import url="/styles/xsl-xhtml.jsp" var="xslt"/>
> <x:transform source="$xml" xslt="$xslt"/>
> 
> __________________________________________________
> Do You Yahoo!?
> Send FREE video emails in Yahoo! Mail!
> http://promo.yahoo.com/videomail/
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>