This documentation is a bit out of date, I think, although it is a minor sin in this case. Cocoon has its own Request and Response interfaces (looking at the implementors this is perhaps because they also handle the command line interactions, not just the servlet interfactions). Look at the API docs (http://cocoon.apache.org/2.1/apidocs/index.html) for more info. As it happens, the APIs for these interfaces are the same as HttpServletRequest and HttpServletResponse, so except when you need to declare the type (as in your example), you can use these objects in the same fashion.
Even the API docs are out of date - the comment for HttpResponse still says it implements HttpServletResponse :)
You can declare your constructor to use org.apache.cocoon.environment.Request and ....Response.
-Christopher
Gianluca Sartori <[EMAIL PROTECTED] To: [EMAIL PROTECTED] rg> cc: Subject: request & response objects 10/20/2003 09:35 AM Please respond to users
Hi,
I'm slowly getting into coccon. I read I can use "request" and "response" objects in XSP pages from my Java code. The official documentation says these objects are instances of HTTPServletRequest/Response, but is it really true?
I'm instantiating an object whose constructor accepts two arguments as follow:
public TheClass (HttpServletRequest request, HttpServletResponse response)
When I try to instantiate an object out of this class cocoon ends up with an error complaining about an undefined constructor. Here is how I instantiated the object:
<?xml version="1.0" encoding="UTF-8"?> <xsp:page xmlns:xsp="http://apache.org/xsp"> <xsp:structure> <xsp:include>org.mysite.*</xsp:include> </xsp:structure>
<my-root-element> <xsp:expr>new TheClass(request, response)</xsp:expr> [...]
This gets translated into the following code:
[...] XSPObjectHelper.xspExpr(contentHandler, new WASClient(request, response)); [...]
And the error returned by cocoon is:
org.apache.cocoon.components.language.LanguageException: Error compiling test_xsp: ERROR 1 (org/apache/cocoon/www/projects/was/docs/test_xsp.java): ... this.characters("\n\n"); // start error (lines 104-104) "The constructor WASClient(Request, Response) is undefined" XSPObjectHelper.xspExpr(contentHandler, new WASClient(request, response)); // end error this.characters("\n\n"); ... Line 104, column 0: The constructor WASClient(Request, Response) is undefined
A comment into the generated code makes me think about the correctness of the documentation, here it is:
/* Built-in parameters available for use */ // context - org.apache.cocoon.environment.Context // request - org.apache.cocoon.environment.Request // response - org.apache.cocoon.environment.Response
So, what should I do to make my Object working? I'm using HTTPServletRequest/Response ad, to say the thruth, I'm not so happy changing them to be used in coccon. Anyway, if you tell me this is the only way to go...
I seem to think there was some discussion about allowing the real HTTPServletRequest (held as a private member in the http impl of the abstract o.a.c.environment.Request) to be accessible. You may want to check the dev list archives for references to this. I don't think it was implemented but you could check that too.
Geoff
Geoff
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]