You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Peter Velychko <v_...@ukr.net> on 2003/05/05 05:24:36 UTC

Passing parameters to XSP from sitemap

Hi all,

I am trying to pass parameters to XSP from sitemap.

My sitemap:
<map:match pattern="*/data/**">
  <map:generate type="serverpages" src="data/{2}.xsp">
    <map:parameter name="lang" value="{1}"/>
  </map:generate>
  <map:serialize type="xml"/>
</map:match>

My xsp:
<?xml version="1.0" encoding="windows-1251"?>
<xsp:page language="java" 
                  xmlns:xsp="http://apache.org/xsp" 
                  xmlns:esql="http://apache.org/cocoon/SQL/v2">
<data>
  <xsp:logic>
    String lang = parameters.getParameter("lang");
  </xsp:logic>
  <news>
    <esql:connection>
      <esql:pool>mypooldb</esql:pool>
      <esql:execute-query>
        <esql:query name="news_list">
          select ld.subject, ld.annotation
          from langdocument ld
          where ld.document_id=65
            and ld.language='<xsp:expr>lang</xsp:expr>'
        </esql:query>
        <esql:results>
          <esql:row-results>
            <item>
              <subject><esql:get-string column="subject"/></subject>
              <annotation><esql:get-string column="annotation"/></annotation>
            </item>
          </esql:row-results>
        </esql:results>
        <esql:no-results>No results</esql:no-results>
        <esql:error-results>Errors</esql:error-results>
      </esql:execute-query>
    </esql:connection>
  </news>
</data>
</xsp:page>


When I request the page "http://localhost:8888/myproject/en/data/news" I have the following error:
org.apache.cocoon.ProcessingException: Language Exception: org.apache.cocoon.components.language.LanguageException: Error compiling news_xsp:
ERROR 1 (org\apache\cocoon\www\antanta\data\news_xsp.java):
...

this.characters("\n");

// start error (lines 306-306) "Unhandled exception type ParameterException"
String lang = parameters.getParameter("lang");

// end error
String current_id =

(
(XSPRequestHelper.getParameter(objectModel,

...
Line 306, column 0: Unhandled exception type ParameterException

What is wrong?

My environment is the following: tomcat 4.1.18, cocoon 2.1M1, Win XP.

-- 
Best regards,
Peter
mailto:v_peter@ukr.net


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


Re: Passing parameters to XSP from sitemap

Posted by Peter Velychko <v_...@ukr.net>.
Hi all!

I've solved my problem. The correct line in XSP should be the following:
String lang = parameters.getParameter("lang", null);

PV> Hi all,

PV> I am trying to pass parameters to XSP from sitemap.

PV> My sitemap:
PV> <map:match pattern="*/data/**">
PV>   <map:generate type="serverpages" src="data/{2}.xsp">
PV>     <map:parameter name="lang" value="{1}"/>
PV>   </map:generate>
PV>   <map:serialize type="xml"/>
PV> </map:match>

PV> My xsp:
PV> <?xml version="1.0" encoding="windows-1251"?>
PV> <xsp:page language="java" 
PV>                   xmlns:xsp="http://apache.org/xsp" 
PV>                   xmlns:esql="http://apache.org/cocoon/SQL/v2">
PV> <data>
PV>   <xsp:logic>
PV>     String lang = parameters.getParameter("lang");
PV>   </xsp:logic>
PV>   <news>
PV>     <esql:connection>
PV>       <esql:pool>mypooldb</esql:pool>
PV>       <esql:execute-query>
PV>         <esql:query name="news_list">
PV>           select ld.subject, ld.annotation
PV>           from langdocument ld
PV>           where ld.document_id=65
PV>             and ld.language='<xsp:expr>lang</xsp:expr>'
PV>         </esql:query>
PV>         <esql:results>
PV>           <esql:row-results>
PV>             <item>
PV>               <subject><esql:get-string column="subject"/></subject>
PV>               <annotation><esql:get-string column="annotation"/></annotation>
PV>             </item>
PV>           </esql:row-results>
PV>         </esql:results>
PV>         <esql:no-results>No results</esql:no-results>
PV>         <esql:error-results>Errors</esql:error-results>
PV>       </esql:execute-query>
PV>     </esql:connection>
PV>   </news>
PV> </data>
PV> </xsp:page>


PV> When I request the page "http://localhost:8888/myproject/en/data/news" I have the following error:
PV> org.apache.cocoon.ProcessingException: Language Exception: org.apache.cocoon.components.language.LanguageException: Error compiling news_xsp:
PV> ERROR 1 (org\apache\cocoon\www\antanta\data\news_xsp.java):
PV> ...

PV> this.characters("\n");

PV> // start error (lines 306-306) "Unhandled exception type ParameterException"
PV> String lang = parameters.getParameter("lang");

PV> // end error
PV> String current_id =

PV> (
PV> (XSPRequestHelper.getParameter(objectModel,

PV> ...
PV> Line 306, column 0: Unhandled exception type ParameterException

PV> What is wrong?

PV> My environment is the following: tomcat 4.1.18, cocoon 2.1M1, Win XP.




-- 
Best regards,
 Peter                            mailto:v_peter@ukr.net


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