You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xang-dev@xml.apache.org by Andy Glick <an...@home.com> on 2000/09/12 05:12:14 UTC
problems with internal urls and directory specifications
When I first began using the 0.0.2 release of Xang I ran into a fair
amount of difficulty. Since then I have downloaded the cvs repository
and rebuilt Xang with the Xerces 1.0.3 and Xalan 1.0.1 jars which
shipped with Cocoon 1.74. I've been running both Cocoon and Xang with
standalone Tomcat 3.1.
I no longer have any java/servlet problems. All of my recent problems
have been with the contents of the various sample files.
I had problems with the following file url in the file system.script.xml
which appeared in the javascript function get() in both the fs2http and
the hello samples.
layout =
"file:///"+Packages.org.apache.xang.util.ServletUtil.resolveURL(layout);
When I modified the code to use an HTTP URL it worked.
layout =
"http://localhost:8080/"+Packages.org.apache.xang.util.ServletUtil.resolveURL(layout);
I also had difficulty with the following definition which I found
throughout fs2http.xap
var fs_root_path = "d:/apache/htdocs/";
when I replaced it with my "docRoot", see below, it worked.
var fs_root_path = "h:/devel3/jakarta-tomcat/webapps/ROOT/";
In both the fs2http and the hello version of editor_browser.xsl I found
the following hardcoded references. When I modified them to conform to
my own directory structure, I got better results.
<!ENTITY baseResourcePath "/xap/apps/apache/" >
<!ENTITY baseURL "/xap/apps/apache/hello/hello.xap/" >
When I display the hello.xap page I get text that looks like this:
"Apache Xang
Welcome to the Next Web Revolution!
Do Base64 stuff
view script"
The problem that I am having is that the URL listed when I mouseover
the "view script" is
http://localhost:8080/xang-hello/?do:method=script
which returns the directory listing for the xang-hello directory rather
than the following URL
http://localhost:8080/xang-hello/hello.xap?do:method=script
which generates an html page with what I presume are the appropriate
javascript functions, and which I also presume satisfies the intention
of the directive "method=script".
Using the URL
http://localhost:8080/xang-hello/hello.xap?do:method=browse
I was able to get a directory listing, but the URL of the image
folder.gif wasn't correct, and that fix required the modification
of layouts\editor_browse.xsl. The text,
<img border='0' src="&baseResourcePath;images/folder.gif" />
worked when modified to:
<img border='0' src="&baseResourcePath;/images/folder.gif" />
I'm not sure that I can account for or explain these problems and or
their solutions, I'm not really much of a web app designer or
implementor. I just wanted to see if I could get Xang to work as
advertised.
With a fair amount of tweaking I can get both of the samples to do
things, but I've been so busy working around the various problems
that I'm no longer sure that I know what the actual intent of the Xang
system is.
RE: problems with internal urls and directory specifications
Posted by "S. Mike Dierken" <mi...@KnowNow.com>.
Andy,
Thanks for the detailed list of issues.
> I no longer have any java/servlet problems. All of my recent problems
> have been with the contents of the various sample files.
Yes, the sample files have too many hardcoded things.
I apologize for the samples not working out of the box, but I didn't know
what all the issues were with different web servers and servlet engines. I
was hoping for exactly this kind of feedback to help with improving the
samples. I will work on making things for adaptable to the environment,
rather than requiring small tweaks.
(But it is nice that only small tweaks to simple text files were needed.)
>
> I had problems with the following file url in the file system.script.xml
> which appeared in the javascript function get() in both the fs2http and
> the hello samples.
>
> layout =
> "file:///"+Packages.org.apache.xang.util.ServletUtil.resolveURL(layout);
>
> When I modified the code to use an HTTP URL it worked.
>
> layout =
>
"http://localhost:8080/"+Packages.org.apache.xang.util.ServletUtil.resolveUR
L(layout);
>
I will look into this to find out why file: access doesn't work. There is no
real reason why file: is required. I just thought it might be faster.
> I also had difficulty with the following definition which I found
> throughout fs2http.xap
>
> var fs_root_path = "d:/apache/htdocs/";
>
> when I replaced it with my "docRoot", see below, it worked.
>
> var fs_root_path = "h:/devel3/jakarta-tomcat/webapps/ROOT/";
>
This sample is an example of poor coding. This root_path should not have
been hardcoded.
> The problem that I am having is that the URL listed when I mouseover
> the "view script" is
>
> http://localhost:8080/xang-hello/?do:method=script
>
This is caused by the original url to the .xap file not having a trailing
slash. It's a never ending problem. This can be resolved by changing the
default get() behavior to check for a trailing slash & if it is missing,
then send a re-direct to the browser with a URL with a trailing slash. This
is what many Web servers do when viewing directories.
Alternatively, the XSL that generates <img src=''> and <a href=''> tags can
be adjusted. Which is what is sounds like you ended up doing.
If you'd like, I can work on changing the default get() to check for a
trailing slash & do a re-direct. Let me know.
>
> I'm not sure that I can account for or explain these problems and or
> their solutions, I'm not really much of a web app designer or
> implementor. I just wanted to see if I could get Xang to work as
> advertised.
>
> With a fair amount of tweaking I can get both of the samples to do
> things, but I've been so busy working around the various problems
> that I'm no longer sure that I know what the actual intent of the Xang
> system is.
>
I'm sorry that there were so many little obstacles. The intent of the Xang
system is that you CAN resolve problems with apps without knowing heavier
languages and doing compile/link/deploy sorts of things.
The Xang system is meant to be a multi-scripting language way to quickly
write web aware and XML aware apps. In addition it will support different
APIs to get the HTTP information. For example, today you use the Java
Servlet API to get stuff from HTTP requests and fill out HTTP responses.
Some programmers are more familiar with the MS ASP model of HTTP Request and
Response. I intend to write an adapter so that your JavaScript can use
either approach. This would be specified in the XML of the app with
something like <xap model='servlet'> or <xap model='asp'> or something.
Please don't get discouraged. The system is rough right now, but with
valuable and intelligent feedback like yours, it will improve quickly and
radically.
Mike
RE: problems with internal urls and directory specifications
Posted by "S. Mike Dierken" <mi...@KnowNow.com>.
Andy,
Here is some script which will resolve the missing trailing slash problem:
// require a trailing slash.
var path;
path = context.getRequest().getPathInfo();
if (path.charAt(path.length-1) != '/')
{
app.redirectTo(context,path+"/");
return;
}
This goes in system.script.xml in the get() function, below the check for
"if (xml == null)".
Unfortunately, there are several copies of system.script.xml. I'll change
the samples to move the system.script.xml file to a parent directory, and
have all apps include that one.
Mike