You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Lenya L. Khachaturov" <le...@chemsell.yaroslavl.ru> on 2002/12/24 14:57:58 UTC

Inserting form data into DB using ESQL - doesn't work

Hello,

I have a form, with action="admin.xsp", a sitemap entry:

<map:match pattern="admin/admin.xsp">
  <map:generate src="admin/admin.xsp" type="serverpages"/>
  <map:serialize/>
</map:match>

and an XSP page:

<?xml version="1.0" encoding="UTF-8"?>
<xsp:page language="java"
xmlns:xsp-request="http://apache.org/xsp/request/2.0"
xmlns:xsp="http://apache.org/xsp"
xmlns:sql="http://apache.org/cocoon/SQL/2.0">
  <page>
  <xsp:logic>
  String title = <xsp-request:get-parameter name="title"/>; 
  String date = <xsp-request:get-parameter name="date"/>;
  String content = <xsp-request:get-parameter name="content"/>;
  String category = <xsp-request:get-parameter name="category"/>;
  String posted_by = <xsp-request:get-parameter name="posted_by"/>;												
  <execute-query xmlns="http://apache.org/cocoon/SQL/2.0">
  <query>INSERT INTO blog_data (title, date, content, category, posted_by) VALUES <parameter>title</parameter>, <parameter>date</parameter>, <parameter>content</parameter>, <parameter>category</parameter>, <parameter>posted_by</parameter></query>	    </execute-query>
  </xsp:logic>
  </page>
  </xsp:page>

The fields' names in the form are the same as in the DB. I'm having no
error messages, everything seems fine, but the output I get is:

INSERT INTO blog_data (title, date, content, category, posted_by) VALUES
title, date, content, category, posted_by

If we look at the page's code, it's:
<page xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-request="http://apache.org/xsp/request/2.0"
xmlns:sql="http://apache.org/cocoon/SQL/2.0">
 <execute-query xmlns="http://apache.org/cocoon/SQL/2.0">
 <query>INSERT INTO blog_data (title, date, content, category, posted_by) VALUES <parameter>title</parameter>, <parameter>date</parameter>, <parameter>content</parameter>, <parameter>category</parameter>, <parameter>posted_by</parameter></query>
 </execute-query>
 </page>

So, the code got through the Server Pages generator fine, but not through
ESQL. Also, parameters, such as <parameter>content</parameter> weren't
substituted with their real values from the request. 

What's wrong with my code?
												
-- 
Lenya Khachaturov
mailto:lenya@chemsell.yaroslavl.ru

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

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


RE: Inserting form data into DB using ESQL - doesn't work

Posted by Geoff Howard <co...@leverageweb.com>.
Well, for starters where did you get the namespace you're using for esql?
The one in 2.x and 2.1 is http://apache.org/cocoon/SQL/v2.

You also should need xsp:expr around your java variable names, even within
esql:parameter.

Finally, you may be getting into trouble declaring the namespace on the
execute-query element instead of using the esql ns-prefix.  In theory what
you are doing should work, but if you're having trouble it's an obvious easy
fix and has caused trouble in the past IIRC because of the inner workings of
some logicsheets.

Hope that helps,
Geoff Howard

> -----Original Message-----
> From: Lenya L. Khachaturov [mailto:lenya@chemsell.yaroslavl.ru]
> Sent: Tuesday, December 24, 2002 8:58 AM
> To: cocoon-users@xml.apache.org
> Subject: Inserting form data into DB using ESQL - doesn't work
>
>
> Hello,
>
> I have a form, with action="admin.xsp", a sitemap entry:
>
> <map:match pattern="admin/admin.xsp">
>   <map:generate src="admin/admin.xsp" type="serverpages"/>
>   <map:serialize/>
> </map:match>
>
> and an XSP page:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsp:page language="java"
> xmlns:xsp-request="http://apache.org/xsp/request/2.0"
> xmlns:xsp="http://apache.org/xsp"
> xmlns:sql="http://apache.org/cocoon/SQL/2.0">
>   <page>
>   <xsp:logic>
>   String title = <xsp-request:get-parameter name="title"/>;
>   String date = <xsp-request:get-parameter name="date"/>;
>   String content = <xsp-request:get-parameter name="content"/>;
>   String category = <xsp-request:get-parameter name="category"/>;
>   String posted_by = <xsp-request:get-parameter
> name="posted_by"/>;
>
>   <execute-query xmlns="http://apache.org/cocoon/SQL/2.0">
>   <query>INSERT INTO blog_data (title, date, content, category,
> posted_by) VALUES <parameter>title</parameter>,
> <parameter>date</parameter>, <parameter>content</parameter>,
> <parameter>category</parameter>,
> <parameter>posted_by</parameter></query>	    </execute-query>
>   </xsp:logic>
>   </page>
>   </xsp:page>
>
> The fields' names in the form are the same as in the DB. I'm having no
> error messages, everything seems fine, but the output I get is:
>
> INSERT INTO blog_data (title, date, content, category, posted_by) VALUES
> title, date, content, category, posted_by
>
> If we look at the page's code, it's:
> <page xmlns:xsp="http://apache.org/xsp"
> xmlns:xsp-request="http://apache.org/xsp/request/2.0"
> xmlns:sql="http://apache.org/cocoon/SQL/2.0">
>  <execute-query xmlns="http://apache.org/cocoon/SQL/2.0">
>  <query>INSERT INTO blog_data (title, date, content, category,
> posted_by) VALUES <parameter>title</parameter>,
> <parameter>date</parameter>, <parameter>content</parameter>,
> <parameter>category</parameter>, <parameter>posted_by</parameter></query>
>  </execute-query>
>  </page>
>
> So, the code got through the Server Pages generator fine, but not through
> ESQL. Also, parameters, such as <parameter>content</parameter> weren't
> substituted with their real values from the request.
>
> What's wrong with my code?
>
>
> --
> Lenya Khachaturov
> mailto:lenya@chemsell.yaroslavl.ru
>
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@xml.apache.org>
>
>
>


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

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