You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Steve A." <st...@asanderson.com> on 2008/09/02 21:57:59 UTC

using jetty request params in xml-defined route

Scanning the archive, I noticed that a few other folks asked a similar
question, but never got an answer, but mine is a little different.

How can a jetty request parameter be accessed within a xml-defined route?

I see where I can access headers and a the body using <simple>, but I don't
see where request parameters are accessible.

Please advise.

Thanks,

Steve
-- 
View this message in context: http://www.nabble.com/using-jetty-request-params-in-xml-defined-route-tp19277002s22882p19277002.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: using jetty request params in xml-defined route

Posted by "Steve A." <st...@asanderson.com>.

Claus Ibsen wrote:
> 
> Yes please create a JIRA for this as you can only get the http request
> parameters by using a the getHttpRequest on the HttpExchange and thus you
> need java code and can't do it from the simple expression language.
> I think it should be able to access the httprequest parameters from
> exchange.in.header, then its easy to use content based routing as well.
> 

Done. Reference https://issues.apache.org/activemq/browse/CAMEL-877.

It should be a quick fix.

Steve
-- 
View this message in context: http://www.nabble.com/using-jetty-request-params-in-xml-defined-route-tp19277002s22882p19288428.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: using jetty request params in xml-defined route

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

Yes please create a JIRA for this as you can only get the http request parameters by using a the getHttpRequest on the HttpExchange and thus you need java code and can't do it from the simple expression language.

I think it should be able to access the httprequest parameters from exchange.in.header, then its easy to use content based routing as well.




Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk
-----Original Message-----
From: Steve A. [mailto:steve@asanderson.com] 
Sent: 3. september 2008 13:37
To: camel-user@activemq.apache.org
Subject: RE: using jetty request params in xml-defined route




Claus Ibsen wrote:
> 
> Its easier to help if you post a snippet of your route.
> I would assume that the parameters is stored in the in message as headers.
> So you should be able to access them using the simple language from the
> xml routing also.
> <simple>in.header.foo</simple>
> 

Actually, it would be great if that were possible, but as far as I can tell,
the http request parameters never get set in the header nor properties of
the jetty exchange.

e.g. if the request is http://localhost:8080/test?x=1, then x is not
accessible via ${in.header.x}, ${in.body}, or ${property.x}.

<route>
   <from uri="jetty:http://localhost:8080/test" />
   <setBody>
      <simple>&lt;html>&lt;body>${in.header.x}&lt;/body>&lt;/html></simple>
   </setBody>
</route>

Of course, if I replace the <setBody> above to a <process> and create a
Processor Java class that contains the following, then it works, but I'd
like to keep the routes in the Spring xml to the extent possible, since
run-time configuration changes are a major goal:

	public void process(Exchange exchange) throws Exception {
		HttpServletRequest req =
exchange.getIn().getBody(HttpServletRequest.class);
		exchange.getOut(true).setBody("<html><body>" + req.getParameter("x") +
"</body></html>");
	}

Please advise if my understanding of how this works is incorrect, or if this
should be a JIRA enhancement for the Jetty component.

Thanks in advance,

Steve
-- 
View this message in context: http://www.nabble.com/using-jetty-request-params-in-xml-defined-route-tp19277002s22882p19287503.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: using jetty request params in xml-defined route

Posted by "Steve A." <st...@asanderson.com>.


Claus Ibsen wrote:
> 
> Its easier to help if you post a snippet of your route.
> I would assume that the parameters is stored in the in message as headers.
> So you should be able to access them using the simple language from the
> xml routing also.
> <simple>in.header.foo</simple>
> 

Actually, it would be great if that were possible, but as far as I can tell,
the http request parameters never get set in the header nor properties of
the jetty exchange.

e.g. if the request is http://localhost:8080/test?x=1, then x is not
accessible via ${in.header.x}, ${in.body}, or ${property.x}.

<route>
   <from uri="jetty:http://localhost:8080/test" />
   <setBody>
      <simple>&lt;html>&lt;body>${in.header.x}&lt;/body>&lt;/html></simple>
   </setBody>
</route>

Of course, if I replace the <setBody> above to a <process> and create a
Processor Java class that contains the following, then it works, but I'd
like to keep the routes in the Spring xml to the extent possible, since
run-time configuration changes are a major goal:

	public void process(Exchange exchange) throws Exception {
		HttpServletRequest req =
exchange.getIn().getBody(HttpServletRequest.class);
		exchange.getOut(true).setBody("<html><body>" + req.getParameter("x") +
"</body></html>");
	}

Please advise if my understanding of how this works is incorrect, or if this
should be a JIRA enhancement for the Jetty component.

Thanks in advance,

Steve
-- 
View this message in context: http://www.nabble.com/using-jetty-request-params-in-xml-defined-route-tp19277002s22882p19287503.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: using jetty request params in xml-defined route

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

Its easier to help if you post a snippet of your route.

I would assume that the parameters is stored in the in message as headers.

So you should be able to access them using the simple language from the xml routing also.

<simple>in.header.foo</simple>


Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: Steve A. [mailto:steve@asanderson.com] 
Sent: 2. september 2008 21:58
To: camel-user@activemq.apache.org
Subject: using jetty request params in xml-defined route


Scanning the archive, I noticed that a few other folks asked a similar
question, but never got an answer, but mine is a little different.

How can a jetty request parameter be accessed within a xml-defined route?

I see where I can access headers and a the body using <simple>, but I don't
see where request parameters are accessible.

Please advise.

Thanks,

Steve
-- 
View this message in context: http://www.nabble.com/using-jetty-request-params-in-xml-defined-route-tp19277002s22882p19277002.html
Sent from the Camel - Users mailing list archive at Nabble.com.