You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Steven Maring <St...@trcinc.com> on 2000/04/06 16:06:40 UTC

whats allowed in an xsp:logic tag?

I have a simple 'try' in an XSP logic-sheet and Cocoon throws an exception:

Cocoon 1.7.2
Error found handling the request.
java.lang.Exception: XSP Java Compiler: Compilation failed for _login.java
        29: Type expected.
                  try {
                  ^



<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xsp="http://www.apache.org/1999/XSP/Core"
>

  <xsl:template match="page">

    <xsl:processing-instruction
name="cocoon-process">type="xsp"</xsl:processing-instruction>
    <xsp:page xmlns:xsp="http://www.apache.org/1999/XSP/Core">

      <xsp:structure>
	<xsp:include>java.util.HashMap</xsp:include>
	<xsp:include>java.net.URL</xsp:include>
      </xsp:structure>

      <xsp:logic>

	  try {
	     HashMap requestParams = DataServletUtils.getParameters( request
);
	     String username = (String) requestParams.get( "username" );
	     String password = (String) requestParams.get( "password" );
				
	     URL url = new URL( "http://luckydog/modelSystem/redirected.xml"
);
	     HashMap responseParams = new HashMap();
	     responseParams.put( "username", username );
	     DataServletUtils.redirect( url, response, responseParams );


	  } catch (Exception e) {
	     e.printStackTrace();
	  }


      </xsp:logic>
      
    </xsp:page>

  </xsl:template>

</xsl:stylesheet>

Re: whats allowed in an xsp:logic tag?

Posted by Eric SCHAEFFER <es...@posterconseil.com>.
Look at the java file created in the repository : if you don't "output" some
tags before java code, you're not in the populateDocument function, you're in
the class declaration. Thus, you can't have statements, just declarations.

Try to "output" your document root tag before your java code, it should work :

>   <xsl:template match="page">
>
>     <xsl:processing-instruction
> name="cocoon-process">type="xsp"</xsl:processing-instruction>
>     <xsp:page xmlns:xsp="http://www.apache.org/1999/XSP/Core">
>
>       <xsp:structure>
> <xsp:include>java.util.HashMap</xsp:include>
> <xsp:include>java.net.URL</xsp:include>
>       </xsp:structure>
>
    <root-tag>
>       <xsp:logic>
>
>   try {
>      HashMap requestParams = DataServletUtils.getParameters( request
> );
>      String username = (String) requestParams.get( "username" );
>      String password = (String) requestParams.get( "password" );
>

...

>
>       </xsp:logic>

    </root-tag>
>
>     </xsp:page>
>
>   </xsl:template>



Is it a bug, Pier ?


Eric.

----- Original Message -----
From: Steven Maring <St...@trcinc.com>
To: <co...@xml.apache.org>
Sent: Thursday, April 06, 2000 4:06 PM
Subject: whats allowed in an xsp:logic tag?


> I have a simple 'try' in an XSP logic-sheet and Cocoon throws an exception:
>
> Cocoon 1.7.2
> Error found handling the request.
> java.lang.Exception: XSP Java Compiler: Compilation failed for _login.java
>         29: Type expected.
>                   try {
>                   ^
>
>
>
> <?xml version="1.0"?>
>
> <xsl:stylesheet version="1.0"
>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>   xmlns:xsp="http://www.apache.org/1999/XSP/Core"
> >
>
>   <xsl:template match="page">
>
>     <xsl:processing-instruction
> name="cocoon-process">type="xsp"</xsl:processing-instruction>
>     <xsp:page xmlns:xsp="http://www.apache.org/1999/XSP/Core">
>
>       <xsp:structure>
> <xsp:include>java.util.HashMap</xsp:include>
> <xsp:include>java.net.URL</xsp:include>
>       </xsp:structure>
>
>       <xsp:logic>
>
>   try {
>      HashMap requestParams = DataServletUtils.getParameters( request
> );
>      String username = (String) requestParams.get( "username" );
>      String password = (String) requestParams.get( "password" );
>
>      URL url = new URL( "http://luckydog/modelSystem/redirected.xml"
> );
>      HashMap responseParams = new HashMap();
>      responseParams.put( "username", username );
>      DataServletUtils.redirect( url, response, responseParams );
>
>
>   } catch (Exception e) {
>      e.printStackTrace();
>   }
>
>
>       </xsp:logic>
>
>     </xsp:page>
>
>   </xsl:template>
>
> </xsl:stylesheet>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>