3

I have a template like the following:

    val outMsg = s"${outMap.mkString("<p/>\n")}"

    if (returnMode.equalsIgnoreCase("HTML")) {
      response.setContentType("text/html")
      displayPage("Keywords Query Results:",
        // <p>Query: {jsonObject.get.toString}</p>
        <p>Return:
          {outMsg}

Now what gets sent to browser:

419 iphone ( 2015-05-01 )&lt;p/&gt;
381 iphone ( 2015-05-01  Texas)&lt;p/&gt;
259 iphone ( 2015-05-01  NY)&lt;p/&gt;
148 iphone ( 2015-05-01  Tx)&lt;p/&gt;
131 iphone ( 2015-05-01  CA)&lt;p/&gt;
129 android ( 2015-05-01  TX)&lt;p/&gt;

How to instruct scalatra to "leave the text alone" and send it to browser as-is ?

Update Notice that the code above is inside DisplayPage - which apparently does not allow the macros/markup. I need to understand why the sample programs even use the displayPage at all -and what a better alternative will be.

WestCoastProjects
  • 58,982
  • 91
  • 316
  • 560

2 Answers2

1

You can do it globally:

<% escapeMarkup = false %>

Or wrap the expression:

some text
${unescape(outMsg)}
Ryan Delucchi
  • 7,718
  • 13
  • 48
  • 60
  • OK I am trying it out. – WestCoastProjects Aug 28 '15 at 15:17
  • I have updated OP : the code sent to displayPage can not contain the macro expansions. I need to get a handle on the flow here: the sample programs do use displayPage but then it is broken.. Will update the OP yet again after getting some self education. – WestCoastProjects Aug 28 '15 at 15:28
0

The URLEnocding is occurring due to the xml node's, not specific to scalatra. However, I did not discover how to undo the encoding before scalatra returns the contents to the requestor.

WestCoastProjects
  • 58,982
  • 91
  • 316
  • 560