dims 01/03/25 15:01:18
Modified: src/org/apache/cocoon/components/language/markup/xsp Tag:
xml-cocoon2 XSPRequestHelper.java
src/org/apache/cocoon/components/language/markup/xsp/java
Tag: xml-cocoon2 request.xsl
Added: webapp/docs/samples/xsp Tag: xml-cocoon2 request-test.xsp
Log:
Patches from "Colin Britton" <[EMAIL PROTECTED]> for adding more
functionality to request.xsl
Revision Changes Path
No revision
No revision
1.1.2.9 +195 -1
xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPRequestHelper.java
Index: XSPRequestHelper.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPRequestHelper.java,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- XSPRequestHelper.java 2001/03/23 19:38:06 1.1.2.8
+++ XSPRequestHelper.java 2001/03/25 23:01:16 1.1.2.9
@@ -24,7 +24,7 @@
* The <code>HttpServletRequest</code> object helper
*
* @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
- * @version CVS $Revision: 1.1.2.8 $ $Date: 2001/03/23 19:38:06 $
+ * @version CVS $Revision: 1.1.2.9 $ $Date: 2001/03/25 23:01:16 $
*/
public class XSPRequestHelper extends XSPObjectHelper {
/**
@@ -334,6 +334,199 @@
);
}
+
+ /**
+ * Output the login of the user making the request
+ * Could be null if user is not authenticated.
+ *
+ * @param objectModel The Map objectModel
+ */
+ public static String getRemoteUser(
+ Map objectModel
+ )
+ {
+ HttpRequest request =
(HttpRequest)objectModel.get(Constants.REQUEST_OBJECT);
+ return request.getRemoteUser();
+ }
+
+ /**
+ * Output the login of the user making the request
+ * Could be null if user is not authenticated.
+ *
+ * @param objectModel The Map objectModel
+ * @param contentHandler The SAX content handler
+ * @exception SAXException If a SAX error occurs
+ */
+ public static void getRemoteUser(
+ Map objectModel,
+ ContentHandler contentHandler
+ )
+ throws SAXException
+ {
+ HttpRequest request =
(HttpRequest)objectModel.get(Constants.REQUEST_OBJECT);
+ elementData(contentHandler, "remote-user", request.getRemoteUser());
+ }
+
+
+ /**
+ * Output the name of the HTTP method with which the request was made,
+ *
+ * @param objectModel The Map objectModel
+ */
+ public static String getMethod(
+ Map objectModel
+ )
+ {
+ HttpRequest request =
(HttpRequest)objectModel.get(Constants.REQUEST_OBJECT);
+ return request.getMethod();
+ }
+
+ /**
+ * Output the name of the HTTP method with which the request was made,
+ *
+ * @param objectModel The Map objectModel
+ * @param contentHandler The SAX content handler
+ * @exception SAXException If a SAX error occurs
+ */
+ public static void getMethod(
+ Map objectModel,
+ ContentHandler contentHandler
+ )
+ throws SAXException
+ {
+ HttpRequest request =
(HttpRequest)objectModel.get(Constants.REQUEST_OBJECT);
+ elementData(contentHandler, "method", request.getMethod());
+ }
+
+ /**
+ * Output the query string that is contained in the request URL after
the path,
+ *
+ *
+ * @param objectModel The Map objectModel
+ */
+ public static String getQueryString(
+ Map objectModel
+ )
+ {
+ HttpRequest request =
(HttpRequest)objectModel.get(Constants.REQUEST_OBJECT);
+ return request.getQueryString();
+ }
+
+ /**
+ * Output the query string that is contained in the request URL after
the path,
+ *
+ *
+ * @param objectModel The Map objectModel
+ * @param contentHandler The SAX content handler
+ * @exception SAXException If a SAX error occurs
+ */
+ public static void getQueryString(
+ Map objectModel,
+ ContentHandler contentHandler
+ )
+ throws SAXException
+ {
+ HttpRequest request =
(HttpRequest)objectModel.get(Constants.REQUEST_OBJECT);
+ elementData(contentHandler, "query-string", request.getQueryString());
+ }
+
+ /**
+ * Output the name and version of the protocol the request uses in the
form of
+ * protocol/majorVersion.minorVersion,
+ *
+ * @param objectModel The Map objectModel
+ */
+ public static String getProtocol(
+ Map objectModel
+ )
+ {
+ HttpRequest request =
(HttpRequest)objectModel.get(Constants.REQUEST_OBJECT);
+ return request.getProtocol();
+ }
+
+ /**
+ * Output the name and version of the protocol the request uses in the
form of
+ * protocol/majorVersion.minorVersion,
+ *
+ * @param objectModel The Map objectModel
+ * @param contentHandler The SAX content handler
+ * @exception SAXException If a SAX error occurs
+ */
+ public static void getProtocol(
+ Map objectModel,
+ ContentHandler contentHandler
+ )
+ throws SAXException
+ {
+ HttpRequest request =
(HttpRequest)objectModel.get(Constants.REQUEST_OBJECT);
+ elementData(contentHandler, "protocol", request.getProtocol());
+ }
+
+ /**
+ * Output the fully qualified name of the client that sent the request,
or
+ * the IP address of the client if the name cannot be determined, given
+ * <code>HttpServletRequest</code>
+ *
+ * @param objectModel The Map objectModel
+ */
+ public static String getRemoteHost(
+ Map objectModel
+ )
+ {
+ HttpRequest request =
(HttpRequest)objectModel.get(Constants.REQUEST_OBJECT);
+ return request.getRemoteHost();
+ }
+
+ /**
+ * Output the fully qualified name of the client that sent the request,
or
+ * the IP address of the client if the name cannot be determined, given
+ * <code>HttpServletRequest</code>
+ *
+ * @param objectModel The Map objectModel
+ * @param contentHandler The SAX content handler
+ * @exception SAXException If a SAX error occurs
+ */
+ public static void getRemoteHost(
+ Map objectModel,
+ ContentHandler contentHandler
+ )
+ throws SAXException
+ {
+ HttpRequest request =
(HttpRequest)objectModel.get(Constants.REQUEST_OBJECT);
+ elementData(contentHandler, "remote-user", request.getRemoteHost());
+ }
+
+ /**
+ * Output the IP address of the client that sent the request
+ *
+ * @param objectModel The Map objectModel
+ */
+ public static String getRemoteAddr(
+ Map objectModel
+ )
+ {
+ HttpRequest request =
(HttpRequest)objectModel.get(Constants.REQUEST_OBJECT);
+ return request.getRemoteAddr();
+ }
+
+ /**
+ * Output the IP address of the client that sent the request
+ *
+ * @param objectModel The Map objectModel
+ * @param contentHandler The SAX content handler
+ * @exception SAXException If a SAX error occurs
+ */
+ public static void getRemoteAddr(
+ Map objectModel,
+ ContentHandler contentHandler
+ )
+ throws SAXException
+ {
+ HttpRequest request =
(HttpRequest)objectModel.get(Constants.REQUEST_OBJECT);
+ elementData(contentHandler, "remote-address", request.getRemoteAddr());
+ }
+
+
/**
* Checks the secure flag
*
@@ -486,3 +679,4 @@
request.getSession().removeAttribute(name);
}
}
+
No revision
No revision
1.1.2.11 +157 -8
xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/java/Attic/request.xsl
Index: request.xsl
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/java/Attic/request.xsl,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -u -r1.1.2.10 -r1.1.2.11
--- request.xsl 2001/03/23 19:38:10 1.1.2.10
+++ request.xsl 2001/03/25 23:01:17 1.1.2.11
@@ -11,7 +11,7 @@
<!--
* @author <a href="mailto:[EMAIL PROTECTED]>Ricardo Rocha</a>
- * @version CVS $Revision: 1.1.2.10 $ $Date: 2001/03/23 19:38:10 $
+ * @version CVS $Revision: 1.1.2.11 $ $Date: 2001/03/25 23:01:17 $
-->
<!-- XSP Request logicsheet for the Java language -->
@@ -228,7 +228,155 @@
</xsl:choose>
</xsl:template>
- <xsl:template name="value-for-as">
+<xsl:template match="xsp-request:get-remote-address">
+ <xsl:variable name="as">
+ <xsl:call-template name="value-for-as">
+ <xsl:with-param name="default" select="'string'"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$as = 'string'">
+ <xsp:expr>
+ (XSPRequestHelper.getRemoteAddr(objectModel))
+ </xsp:expr>
+ </xsl:when>
+ <xsl:when test="$as = 'xml'">
+ <xsp:logic>
+ XSPRequestHelper.getRemoteAddr(objectModel, this.contentHandler);
+ </xsp:logic>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="xsp-request:get-remote-user">
+ <xsl:variable name="as">
+ <xsl:call-template name="value-for-as">
+ <xsl:with-param name="default" select="'string'"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$as = 'string'">
+ <xsp:expr>
+ (XSPRequestHelper.getRemoteUser(objectModel))
+ </xsp:expr>
+ </xsl:when>
+ <xsl:when test="$as = 'xml'">
+ <xsp:logic>
+ XSPRequestHelper.getRemoteUser(objectModel, this.contentHandler);
+ </xsp:logic>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="xsp-request:get-server-name">
+ <xsl:variable name="as">
+ <xsl:call-template name="value-for-as">
+ <xsl:with-param name="default" select="'string'"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$as = 'string'">
+ <xsp:expr>
+ (XSPRequestHelper.getServerName(objectModel))
+ </xsp:expr>
+ </xsl:when>
+ <xsl:when test="$as = 'xml'">
+ <xsp:logic>
+ XSPRequestHelper.getServerName(objectModel, this.contentHandler);
+ </xsp:logic>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="xsp-request:get-method">
+ <xsl:variable name="as">
+ <xsl:call-template name="value-for-as">
+ <xsl:with-param name="default" select="'string'"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$as = 'string'">
+ <xsp:expr>
+ (XSPRequestHelper.getMethod(objectModel))
+ </xsp:expr>
+ </xsl:when>
+ <xsl:when test="$as = 'xml'">
+ <xsp:logic>
+ XSPRequestHelper.getMethod(objectModel, this.contentHandler);
+ </xsp:logic>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="xsp-request:get-query-string">
+ <xsl:variable name="as">
+ <xsl:call-template name="value-for-as">
+ <xsl:with-param name="default" select="'string'"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$as = 'string'">
+ <xsp:expr>
+ (XSPRequestHelper.getQueryString(objectModel))
+ </xsp:expr>
+ </xsl:when>
+ <xsl:when test="$as = 'xml'">
+ <xsp:logic>
+ XSPRequestHelper.getQueryString(objectModel, this.contentHandler);
+ </xsp:logic>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="xsp-request:get-protocol">
+ <xsl:variable name="as">
+ <xsl:call-template name="value-for-as">
+ <xsl:with-param name="default" select="'string'"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$as = 'string'">
+ <xsp:expr>
+ (XSPRequestHelper.getProtocol(objectModel))
+ </xsp:expr>
+ </xsl:when>
+ <xsl:when test="$as = 'xml'">
+ <xsp:logic>
+ XSPRequestHelper.getProtocol(objectModel, this.contentHandler);
+ </xsp:logic>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <xsl:template match="xsp-request:get-remote-host">
+ <xsl:variable name="as">
+ <xsl:call-template name="value-for-as">
+ <xsl:with-param name="default" select="'string'"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$as = 'string'">
+ <xsp:expr>
+ (XSPRequestHelper.getRemoteHost(objectModel))
+ </xsp:expr>
+ </xsl:when>
+ <xsl:when test="$as = 'xml'">
+ <xsp:logic>
+ XSPRequestHelper.getRemoteHost(objectModel, this.contentHandler);
+ </xsp:logic>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="value-for-as">
<xsl:param name="default"/>
<xsl:choose>
<xsl:when test="@as"><xsl:value-of select="@as"/></xsl:when>
@@ -256,10 +404,11 @@
<xsl:otherwise>"<xsl:value-of select="$content"/>"</xsl:otherwise>
</xsl:choose>
</xsl:template>
-
+
<xsl:template match="@*|*|text()|processing-instruction()">
- <xsl:copy>
- <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
- </xsl:copy>
- </xsl:template>
-</xsl:stylesheet>
+ <xsl:copy>
+ <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
+ </xsl:copy>
+ </xsl:template>
+
+ </xsl:stylesheet>
\ No newline at end of file
No revision
No revision
1.1.2.1 +20 -0 xml-cocoon/webapp/docs/samples/xsp/Attic/request-test.xsp
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]