cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From William Bagby <willi...@adone.com>
Subject Using HttpSession in XSP
Date Mon, 19 Mar 2001 17:40:22 GMT
I am storing a Config object in the HttpSession.  I would like to be able to
get the Config object from the session in my XSP page.  I have written an
XSP tag library that attempts to do this, but the problem is, I would be
making use of my tags more than once, so I only want to get the Config
object once, then the tags would use Config's methods to get the data from
it.  I cannot seem to firgure out how to do this.

Here's an example of what it is now:

XSP page:

<page>
	<welcome>Hello <config:get name="FirstName"/>, glad to see you
again!</welcome>
	
	<main-section>
		<header>Your Information</header>
		<user-data>
			<first-name><config:get
name="FirstName"/></first-name>
			<last-name><config:get name="LastName"/></last-name>
			<address><config:get name="Address"/></address>
			...
		</user-data>
	</main-section>
</page>

-------------------------------------

config Tag library:

<xsl:template match="config:get">
	<xsp:expr>
		((Config)session.getAttribute( "config" )).get(
"<xsl:value-of select="@name"/>" )	
	</xsp:expr>
</xsl:template>

---------------------------------------

It actually works, but it's ugly and SLOOOOOW.  Like I said, I'd like to
read the Config only once, something like:

Config config = session.getAttribute( "config" );

then have:

<xsl:template match="config:get">
	<xsp:expr>
		config.get( "<xsl:value-of select="@name"/>" )	
	</xsp:expr>
</xsl:template>

but I can't seem to figure out how to do this from within the
PopulateDocument method, which seems to be the only place I have access to
session.

I do of course realize this may not be the best way to do what I want to do,
in fact, it's probably not.  But I want to be *sure* that it's not before I
move on to some other way.  I'd also like to get a better sense of how XSP
works.

Thanks,

William Bagby.

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message