Re: util:get-file-contents with Cocoon2.1-dev

2001-07-19 Thread Arnaud Bienvenu

On Wed, Jul 18, 2001 at 10:40:22AM -0700, Davanum Srinivas wrote:
> Try the latest Code from CVS.
> - Made the encoding attribute optional.

Thanks for replying so fast, this works fine !

> - Fixed relative path problem. (if you specify just "data.txt" it will look under 
>cocoon directory
> for it).

This still doesn't work; when I specify "data.txt", I see the exception :
java.io.FileNotFoundException:
file:/usr/local/soft/jakarta-tomcat-3.2.2/webapps/cocoon (No such file or
directory)

Actually, looking at XSPUtil.relativeFilename(), I see line 102 :
return NetUtils.getPath(context.getResource(filename).toExternalForm());

The getPath() method returns a path, not a filename, so I wonder how it could
work. Moreover, the context.getResource() method calls
javax.servlet.ServletContext.getResource() which needs to have a path begin
with "/" as an argument, according to
http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/ServletContext.html#getResource(java.lang.String)

To say the truth, I would have expected that  could
include a file relatively to the location of the XSP file, and not the cocoon
path. I don't know if it is possible, but it would be great.

> Note that the IOException is thrown by design. The LogicSheet should not "hide" this 
>exception.

Well, in other including utilities you can find in util.xsl (i.e.
util:include-file), all exceptions are catched, so why not for
util:get-file-contents ?

Thank you for your attention.

P.S: Do you think this thread should migrate to cocoon-devel ?
-- 
Arnaud Bienvenu
http://www.generasound.com/

-
Please check that your question has not already been answered in the
FAQ before posting. 

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>




Re: util:get-file-contents with Cocoon2.1-dev

2001-07-18 Thread Davanum Srinivas

Arnaud,

Try the latest Code from CVS.
- Made the encoding attribute optional.
- Fixed relative path problem. (if you specify just "data.txt" it will look under 
cocoon directory
for it).

Note that the IOException is thrown by design. The LogicSheet should not "hide" this 
exception.

Thanks,
dims

--- Arnaud Bienvenu <[EMAIL PROTECTED]> wrote:
> Trying to use  on Cocoon2.1-dev (cvs updated today),
> I noticed three problems :
> - You must specify the encoding attribute, or go to hell
> - You must catch the java.io.IOException, or apply the patch I made for
> util.xsl
> - You must use absolute path for the name of the file
> 
> Since I'm a beginner with java and xsp, don't yell at me. If you find this
> patch is crap, please tell me why and suggest some better solution. And by
> the way, do you known why relative paths won't work ?
> 
> --- src/org/apache/cocoon/components/language/markup/xsp/java/util.xsl
> 2001/07/12 11:03:21   1.5
> +++ src/org/apache/cocoon/components/language/markup/xsp/java/util.xsl
> 2001/07/18 15:08:59
> @@ -240,14 +240,20 @@
>
>  
> 
> -
> -  XSPUtil.getFileContents(
> -XSPUtil.relativeFilename(
> -  String.valueOf(),
> -  this.objectModel
> -), ""
> -  )
> -
> +
> +  String result = "";
> +  try {
> +result = XSPUtil.getFileContents(
> +  XSPUtil.relativeFilename(
> +String.valueOf(),
> +this.objectModel
> +  ), ""
> +);
> +  } catch (Exception e) {
> +getLogger().error("Could not include page", e);
> +  }
> +
> +result
>
> 
> 
> Here is my XSP page (it works for me) :
> 
>language="java"
> xmlns:xsp="http://apache.org/xsp";
> xmlns:util="http://apache.org/xsp/util/2.0";
> >
>  
>   
>  
> 
> 
> -- 
> Arnaud Bienvenu
> http://www.generasound.com/
> 
> -
> Please check that your question has not already been answered in the
> FAQ before posting. 
> 
> To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> For additional commands, e-mail: <[EMAIL PROTECTED]>
> 


=
Davanum Srinivas, JNI-FAQ Manager
http://www.jGuru.com/faq/JNI

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

-
Please check that your question has not already been answered in the
FAQ before posting. 

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>




util:get-file-contents with Cocoon2.1-dev

2001-07-18 Thread Arnaud Bienvenu

Trying to use  on Cocoon2.1-dev (cvs updated today),
I noticed three problems :
- You must specify the encoding attribute, or go to hell
- You must catch the java.io.IOException, or apply the patch I made for
util.xsl
- You must use absolute path for the name of the file

Since I'm a beginner with java and xsp, don't yell at me. If you find this
patch is crap, please tell me why and suggest some better solution. And by
the way, do you known why relative paths won't work ?

--- src/org/apache/cocoon/components/language/markup/xsp/java/util.xsl
2001/07/12 11:03:21 1.5
+++ src/org/apache/cocoon/components/language/markup/xsp/java/util.xsl
2001/07/18 15:08:59
@@ -240,14 +240,20 @@
   
 

-
-  XSPUtil.getFileContents(
-XSPUtil.relativeFilename(
-  String.valueOf(),
-  this.objectModel
-), ""
-  )
-
+
+  String result = "";
+  try {
+result = XSPUtil.getFileContents(
+  XSPUtil.relativeFilename(
+String.valueOf(),
+this.objectModel
+  ), ""
+);
+  } catch (Exception e) {
+getLogger().error("Could not include page", e);
+  }
+
+result
   


Here is my XSP page (it works for me) :

http://apache.org/xsp";
  xmlns:util="http://apache.org/xsp/util/2.0";
>
 
  
 


-- 
Arnaud Bienvenu
http://www.generasound.com/

-
Please check that your question has not already been answered in the
FAQ before posting. 

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>