You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by petra staub <ca...@hotmail.com> on 2002/10/08 10:22:44 UTC

JSTL import question

I use the <c:import> tag for including my general header file.
Parameters such as the title, I pass by parameters:
<c:param name="title" value="myTitle">.

However, in some jsp files I still require some javascript...

What would be a good solution for providing for individual jsp
files some additional code? (without creating a "javascript"
file which is again imported in header.jsp...I would like to
avoid to many file fragments for a single page)

I tried the following but which seems not to work correctly for me.

Any other good ideas?

Thanks a lot!

=======================================================================

header.jsp:
----------
<%@ taglib prefix="c" uri="/WEB-INF/tlds/jstl/c.tld" %>
<head>
    <title><c:out value="${param.titleString}" /></title>

    <c:out value="${param.jScript}" escapeXml="false" />

</head>

some jsp file with javascript code:
----------------------------------
<%@ taglib prefix="c" uri="/WEB-INF/tlds/jstl/c.tld" %>

<html>

<head>
<c:import url="header.jsp" >
    <c:param name="titleString" value="myTitle" />
    <c:param name="jScript">
    <script language="JavaScript" type="text/javascript">
    <!--
    	>>>>> here is some javascript <<<<<
    //-->
    </script>
    </c:param>
</c:import>

<body>
...
...




_________________________________________________________________
Werden Sie Mitglied bei MSN Hotmail, dem größten E-Mail-Service der Welt: 
http://www.hotmail.com/de


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


Re: JSTL import question

Posted by Shawn Bayern <ba...@essentially.net>.
On Tue, 8 Oct 2002, petra staub wrote:

> I use the <c:import> tag for including my general header file.
> Parameters such as the title, I pass by parameters: <c:param
> name="title" value="myTitle">.
> 
> However, in some jsp files I still require some javascript...
> 
> What would be a good solution for providing for individual jsp files
> some additional code? (without creating a "javascript" file which is
> again imported in header.jsp...I would like to avoid to many file
> fragments for a single page)
> 
> I tried the following but which seems not to work correctly for me.

It looks like what you're doing is correct.  How does it fail for you?
(I'm away at a conference, so I can't easily test it myself or look in
closer detail for a few days.)

-- 
Shawn Bayern
"JSTL in Action"   http://www.jstlbook.com


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