Spicing up your Mule response


We often require to display our payload in the browser. Generally the payload we get in the browser as a response is in normal format.

Today I will demonstrate you to get a Mule payload on a browser in a HTML format. You may have used to get your response on a browser in your various Mule projects.

Let’s consider we have a following Mule flow :-
A Http listener followed by a payload component



So, our corresponding Mule flow will be simple like the following :-


Now, if we hit the browser with the url :- http://localhost:8081/test we will get a plain response in our browser like below :-


Now, this is something very plain and usual format of response we use.
How about spicing this response with a bit html code in it ???

So for that we need parse template of Mule ….

Parse template is nothing but a template to spice up your Mule payload. It load the content of a flow-external file into a Mule flow, then use the file as a template into which you can insert data returned as the result of evaluated Mule expressions.



Let create a file response.html and put it under the following location of our project :-

Let our response.html file contains the following :-


And then we will refer this template in our Mule flow .. that’s it…
So our Mule flow will be :-


Corresponding Mule flow will be :-



You can see above we have added <parse-template/> component in our Mule flow.

Now, let’s hit the url again :- http://localhost:8081/test

We will get the following in our browser :-



Just see how the template response.html is parsing the Mule payload and allowing you to customize it in HTML format ..

That’s it … Now you can try this example by your own and can design your own HTML and put different HTML tags to spice up your response..
Happy coding and share your knowledge everywhere :)


Anirban Sen Chowdhary

Anirban Sen Chowdhary is an information technology professional currently working on Java/J2ee, Esb and Integration platform. For more information, please visit http://anirbansenchowdhary.com and you can also follow https://twitter.com/Anir37

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>