Re: JSTL c:import - passing xml fragment as a parameter

2003-03-06 Thread Erik Beijnoff
> Use the escapeXml attribute:
> 
> Hans

Thank you very much! I found the solution and wrote a reply to my own
question with reflections about it just minutes before I got your answer,
but thanks for taking your time.

/Erik Beijnoff
[EMAIL PROTECTED]
[EMAIL PROTECTED]

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

 http://java.sun.com/products/jsp
 http://archives.java.sun.com/jsp-interest.html
 http://forums.java.sun.com
 http://www.jspinsider.com


JSTL c:import - passing xml fragment as a parameter - problem solved! - push template technique with example included!

2003-03-06 Thread Erik Beijnoff
>When you are using the jsp document (xml) syntax, is it possible to
>pass in an xml fragment as a parameter to  and then
>reference the parameter as xml and not escaped text?
...

Whohoo! It worked. It took a lot of spec reading until i realised where the
character conversion occured, but once I found what was wrong, all it took
was one parameter change, and it worked like a charm.

In the document that gets imported (the main layout document), I just had to
specify  to make it not
escape the xml fragment that gets passed in. Simple once I found out.
Difficult when I didn't knew.

If somebodys wondering what I'm up to I've discovered a great way to use jsp
(xml) documents with jstl as a push template technique that makes is
extremely easy to change, or create several different layouts for the whole
page. Quite xslt like in the style I think.

I assume that other people do this as well, but I've never seen any
tutorials or suggestions on this usage before, so I'll explain it briefly:

-

1. The jsp that you call only contains one master c:import statement, where
you specify an optional number of parameters. This page should only contain
content and no html   declarations etc.

2. These parameters gets pushed onto the imported page and fills out the
needed places. The imported page can be specified on runtime, thereby
changing the whole layout of the page, but still keeping the content the
same. Quite like how you change a master stylesheet in xslt and feed the
stylesheet with information on which xml it should include and then let it
*pull* the needed information from the xml files. The only difference with
this approach is that you tell the *content* file to include a layout
document that can be specified at runtime and let the content file *push*
parameters onto the template. It's the other way around, sort of.

3. If the jsp document (xml) syntax is used, the validity of the generated
(xml) file can always be guaranteed, since the page won't compile unless the
document is wellformed xml. Therefore only wellformed xml fragments can be
generated.

Example:


This is the jsp content file that is requested. Lets call it content.jsp For
the moment this page includes  "/WEB-INF/jspf/main.jsp" but it could as
easily include the other file "/WEB-INF/jspf/print.jsp" instead. This could
be done directly by request parameters, so that the user could switch skins
by himself, or it could be set as a parameter in the session, or any place
else. You can create as many skins as you like, all with the same content.
If you craft your content files well, all css styling can be changed on the
fly too, to change the whole look of the content, for example to provide a
high contrast skin page.


http://java.sun.com/JSP/Page";
 xmlns:c="http://java.sun.com/jstl/core";
 version="1.2">



  

  
  
   p{
  font-size:36px;
   }
  
  

  
   I am a title
  

  
  
 I am content
 
  
  





-
The default layout page, main.jsp, note that the imported files menu.jsp and
footer.jsp does not exist, you have to create them yourself


http://java.sun.com/JSP/Page";
 xmlns:c="http://java.sun.com/jstl/core";
 version="1.2">


http://www.w3.org/1999/xhtml"; xml:lang="en">

   

   


   
  

 



 

  
   





-
A stripped down version, print.jsp, that could be imported from content.sp
instead. Note that this page does not use all parameters sent to it


http://java.sun.com/JSP/Page";
 xmlns:c="http://java.sun.com/jstl/core";
 version="1.2">
 

http://www.w3.org/1999/xhtml"; xml:lang="en">
   
  
   

   
  

  
  
  
   





/Erik Beijnoff
Addsystems
[EMAIL PROTECTED]

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

 http://java.sun.com/products/jsp
 http://archives.java.sun.com/jsp-interest.html
 http://forums.java.sun.com
 http://www.jspinsider.com


Re: JSTL c:import - passing xml fragment as a parameter

2003-03-06 Thread Hans Bergsten
Erik Beijnoff wrote:
When you are using the jsp document (xml) syntax, is it possible to pass in
an xml fragment as a parameter to  and then reference the
parameter as xml and not escaped text?
Import statement:

...

A text

...

Referenced file:

http://java.sun.com/JSP/Page";
xmlns:c="http://java.sun.com/jstl/core";
version="1.2">
http://www.w3.org/1999/xhtml"; xml:lang="en">
...



...

Unfortunately the text that gets output in c:out is escaped text and not
xml: "

A text

" and not "A text" Is there a way to do it? And if not, is there another suitable solution? Use the escapeXml attribute: Hans -- Hans Bergsten<[EMAIL PROTECTED]> Gefion Software Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0 Details at === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant archives, FAQs and Forums on JSPs can be found at: http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com

JSTL c:import - passing xml fragment as a parameter

2003-03-06 Thread Erik Beijnoff
When you are using the jsp document (xml) syntax, is it possible to pass in
an xml fragment as a parameter to  and then reference the
parameter as xml and not escaped text?

Import statement:

...

A text

...


Referenced file:

http://java.sun.com/JSP/Page";
xmlns:c="http://java.sun.com/jstl/core";
version="1.2">
http://www.w3.org/1999/xhtml"; xml:lang="en">
...



...


Unfortunately the text that gets output in c:out is escaped text and not
xml: "

A text

" and not "A text" Is there a way to do it? And if not, is there another suitable solution? Regards Erik Beijnoff [EMAIL PROTECTED] === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant archives, FAQs and Forums on JSPs can be found at: http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com