um, <addcomment> is your tag, in your code below. Put your xsp:logic block inside your addcomment block.
Davide <[EMAIL PROTECTED]>
01/03/2004 03:02 PM
|
To: [EMAIL PROTECTED] cc: Subject: Re: Problems with date and xsp |
Thanks a lot, but now the problem is: what is <addcomment> and where do I need to put it?
You are instantiating your Date variable at the class level, when the page is instantiated. Cocoon re-uses the page object (just calling the generate() method each time), AFAIK. So you need to put your Date instantiation inside the generate() method by doing the logic block inside <addcomment>. That way you will get the current date each time the page is requested, instead of just the first time.
-Christopher
Davide <[EMAIL PROTECTED]>
01/03/2004 02:26 PM
Please respond to users
To: [EMAIL PROTECTED]
cc:
Subject: Problems with date and xsp
Hi, i have some problems in getting the actual timestamp to put it into a db.
My xsp is:
<?xml version="1.0"?>
<xsp:page language="java"
xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-request="http://apache.org/xsp/request/2.0"
xmlns:xsp-session-fw="http://apache.org/xsp/session-fw/1.0"
xmlns:esql="http://apache.org/cocoon/SQL/v2">
<xsp:logic>
java.util.Date now=new java.util.Date();
</xsp:logic>
<addcomment>
<page-title>Add a comment</page-title>
<!-- header bar background source file -->
<bg>images/logobg.gif</bg>
<!-- mcnavigator css -->
<css>css/main.css</css>
<esql:connection>
<esql:pool>mcnavigator</esql:pool>
<esql:execute-query>
<esql:query>Insert into comments (User_ID, Comment_text, Commented_URL,
Comment_Date, Comment_browser) values (
'<xsp-session-fw:getxml context="authentication"
path="/authentication/ID"/>',
'<xsp-request:get-parameter name="comment_text"/>',
'<xsp-request:get-parameter name="link"/>',
'<xsp:expr>new java.sql.Timestamp(now.getTime())</xsp:expr>',
'<xsp-request:get-header name="user-agent"/>')
</esql:query>
<esql:error-results>An error occurred</esql:error-results>
<esql:update-results>
<message>Your comment has ben added; you can now close this
window</message>
</esql:update-results>
</esql:execute-query>
</esql:connection>
</addcomment>
</xsp:page>
The problem is that every time i add a new record to the db using this xsp
i notice that the time doesn't change. Any solution??
Best Regards, Davide
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]