You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Boisvert, Éric" <eb...@nrcan.gc.ca> on 2004/09/21 14:11:37 UTC
spaces in request-param
Greetings
I'm trying to solve a problem that I think is a very basic functionality. I
simply cannot believe there are no way to do this, but after 2 days googling
aroung,. I still don't find a solution to this.
I'm trying to pass request-parameter that contains spaces to a generator ,
using this pipeline:
<map:pipeline>
<map:match pattern="gazetteer">
<map:generate type="file"
src="http://cgdi-dev.geoconnections.org/cgi-bin/prototypes/cgdigaz/cgdigaz.c
gi?version=1.0&request=GetPlacenameGeometry&geomtype=bbox&PLACEN
AME={raw-request-param:PLACE}"/>
<map:transform type="xslt" src="style/gaz_result.xslt"/>
<map:serialize type="html"/>
</map:match>
</map:pipeline>
This works fine with a single word (such as 'Toronto') but fails with a name
containing a space (eg. 'Black River' or Black%20River or Black+River)
I get a org.apache.cocoon.ProcessingException: Failed to execute pipeline.:
java.io.IOException
The exception stacks starts with
Original Exception: java.io.IOException
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection
.java:591)
at
org.apache.excalibur.source.impl.URLSource.getInputStream(URLSource.java:252
)
at
org.apache.cocoon.components.source.SourceUtil.getInputSource(SourceUtil.jav
a:418)
at
org.apache.cocoon.components.source.SourceUtil.parse(SourceUtil.java:252)
at
org.apache.cocoon.generation.FileGenerator.generate(FileGenerator.java:116)
[...]
and somewhere down this impressive list I see
Caused by: java.io.IOException: Server returned HTTP response code: 400 for
URL:
http://cgdi-dev.geoconnections.org/cgi-bin/prototypes/cgdigaz/cgdigaz.cgi?ve
rsion=1.0&request=GetPlacenameGeometry&geomtype=bbox&PLACENAME=Black River
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection
.java:789)
at
sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection
.java:1446)
at
java.net.HttpURLConnection.getHeaderFieldDate(HttpURLConnection.java:343)
at java.net.URLConnection.getLastModified(URLConnection.java:429)
at
org.apache.excalibur.source.impl.URLSource.getInfos(URLSource.java:160)
at
org.apache.excalibur.source.impl.AbstractSource.checkInfos(AbstractSource.ja
va:58)
at
org.apache.excalibur.source.impl.AbstractSource.getLastModified(AbstractSour
ce.java:138)
at
org.apache.excalibur.source.impl.URLSource.getValidity(URLSource.java:265)
at
org.apache.cocoon.generation.FileGenerator.getValidity(FileGenerator.java:10
2)
at
org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline
.getValidityForInternalPipeline(AbstractCachingProcessingPipeline.java:897)
at
org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline
.setupValidities(AbstractCachingProcessingPipeline.java:399)
at
org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline
.setupPipeline(AbstractCachingProcessingPipeline.java:655)
at
org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.preparePipe
line(AbstractProcessingPipeline.java:506)
at
org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.process(Abs
tractProcessingPipeline.java:464)
... 59 more
Of course, if I copy this URL
(http://cgdi-dev.geoconnections.org/cgi-bin/prototypes/cgdigaz/cgdigaz.cgi?v
ersion=1.0&request=GetPlacenameGeometry&geomtype=bbox&PLACENAME=Black
River)and copy it in a browser, it works fine
I get the same exception wheter I use %20 or +, etc..
Any clue ? Sorry if I missed something obvious but I search and did not
find anything. I can't believe I'm the only one passing parameters with
spaces in the whole cocoon community !
Cheers and thanks
================================================================
Eric Boisvert
Spécialiste TI-GI / IT-IM specialist
eboisver@nrcan.gc.ca, 418-654-3705, facsimile/télécopieur
418-654-2615
880 Chemin Ste-Foy, Bureau 840, Québec (Québec), G1S 2L2
880 Ste-Foy street, Room 840, Quebec, Quebec, G1S 2L2
Laboratoire de cartographie numérique et de photogrammétrie (LCNP)
Digital Cartography and Photogrammetry Laboratory (DCPL)
Commission géologique du Canada (Québec) / Geological Survey of Canada
(Quebec)
Ressources naturelles Canada / Natural Resources Canada
Gouvernement du Canada / Government of Canada
http://www.cgcq.rncan.gc.ca/lcnp
http://www.nrcan.gc.ca/gsc
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: spaces in request-param
Posted by "g[R]eK" <gR...@warsztat.pac.pl>.
<. Hi Éric! .>
Tuesday, September 21, 2004, 2:11:37 PM, you wrote:
BÉ> Greetings
BÉ> I'm trying to solve a problem that I think is a very basic functionality. I
BÉ> simply cannot believe there are no way to do this, but after 2 days googling
BÉ> aroung,. I still don't find a solution to this.
BÉ> I'm trying to pass request-parameter that contains spaces to a generator ,
BÉ> using this pipeline:
BÉ> <map:pipeline>
BÉ> <map:match pattern="gazetteer">
BÉ> <map:generate type="file"
BÉ> src="http://cgdi-dev.geoconnections.org/cgi-bin/prototypes/cgdigaz/cgdigaz.c
BÉ> gi?version=1.0&request=GetPlacenameGeometry&geomtype=bbox&PLACEN
BÉ> AME={raw-request-param:PLACE}"/>
I'm not sure why raw-request-param is used. To avoid decoding and casting? I
think it's not good practice. Try to use url-encode[1] and request-param
modules:
{url-encode:{request-param:PLACE}}
It works for me very well.
<snip/>
BÉ> and somewhere down this impressive list I see
BÉ> Caused by: java.io.IOException: Server returned HTTP response code: 400 for
BÉ> URL:
BÉ> http://cgdi-dev.geoconnections.org/cgi-bin/prototypes/cgdigaz/cgdigaz.cgi?ve
BÉ> rsion=1.0&request=GetPlacenameGeometry&geomtype=bbox&PLACENAME=Black River
BÉ> at
RFC[2] says:
400 Bad Request
The request could not be understood by the server due to malformed syntax.
I think it's error due to not escapted spaces or other characters.
BÉ> Of course, if I copy this URL
BÉ> (http://cgdi-dev.geoconnections.org/cgi-bin/prototypes/cgdigaz/cgdigaz.cgi?v
BÉ> ersion=1.0&request=GetPlacenameGeometry&geomtype=bbox&PLACENAME=Black
BÉ> River)and copy it in a browser, it works fine
AFAIK Browsers escape charactacters automatically.
BÉ> Any clue ? Sorry if I missed something obvious but I search and did not
BÉ> find anything. I can't believe I'm the only one passing parameters with
BÉ> spaces in the whole cocoon community !
Hope this help.
[1] http://localhost:8080/cocoon/api/java/org/apache/cocoon/components/modules/input/URLEncodeModule.html
(I give you local link because javadocs on cocoon's site seem to be outdate)
[2] http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
--
Best regards
<. g[R]eK mailto:gReK@warsztat.pac.pl .>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org