Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. If you'd prefer to explore, try our test area to get started. And see here for current known issues.

New Member

Line breaks in IE and Outlook

Anyone had success with getting Java Text to go over to IE with the line breaks?

After trigging a HTTP Trigger, I wish to send the results back to a browser.

Send Http Response Document would have the following text inside.

I've tried this:

TEXT["Script has started!"
+ u"'\r\n'Type of Call is " + strTaskType
+ u"'\r\n'Task ID is " +  strTaskID
+ u"'\r\n'Response Code was " + strResponse]

and this:

TEXT["Script has started! " + '\r'
+ "Type of Call is " + strTaskType + '\r'
+ "Task ID is " +  strTaskID + '\r'
+ "Response Code was " + strResponse]

and this:

TEXT["Script has started! " + '\r' + '\n'
+ "Type of Call is " + strTaskType + '\r' + '\n'
+ "Task ID is " +  strTaskID + '\r' + '\n'
+ "Response Code was " + strResponse]

IE I get the following result:

Script has started! Type of Call is "1" Task ID is "12345" Response Code was 8

Google Chrome I get the result I want:

Script has started!

Type of Call is "1"

Task ID is "12345"

Response Code was 8

But the majority of my users use MS products and I don't want to ask them to download another browser that I would have to support.

 

Everyone's tags (5)
1 ACCEPTED SOLUTION

Accepted Solutions

Hi,it's not a bug, it's a

Hi,

it's not a bug, it's a feature. Actually, browsers may indeed ignore \r and \n characters and their combinations. But they cannot ignore proper HTML tags like </br> or <p>

Let's serve HTML - with the guarrantee that it would appear as expected in all browsers - by our script.

Also, I would like to show you that there's a more elegant way of concatenating strings which is a bit easier on the JDK as well: StringBuffer.

First, let's add a new variable to the script:

Name: sb

Type: StringBuffer

Value: new StringBuffer()

Then use the following construct:

sb.append("text")

or even

sb.append("text1").append("text2").append("text3")

Also notice I use the &nbsp; notation for inserting a non-breaking space.

Finally, within the Send HTTP Response step we take the string value of the sb variable, and we also cast it to a Document type, like this: (Document) sb.toString()

Here's a screenshot:

 

And this is presented in IE, the bestest of the browsers:

 

G.

 

 


 

1 REPLY

Hi,it's not a bug, it's a

Hi,

it's not a bug, it's a feature. Actually, browsers may indeed ignore \r and \n characters and their combinations. But they cannot ignore proper HTML tags like </br> or <p>

Let's serve HTML - with the guarrantee that it would appear as expected in all browsers - by our script.

Also, I would like to show you that there's a more elegant way of concatenating strings which is a bit easier on the JDK as well: StringBuffer.

First, let's add a new variable to the script:

Name: sb

Type: StringBuffer

Value: new StringBuffer()

Then use the following construct:

sb.append("text")

or even

sb.append("text1").append("text2").append("text3")

Also notice I use the &nbsp; notation for inserting a non-breaking space.

Finally, within the Send HTTP Response step we take the string value of the sb variable, and we also cast it to a Document type, like this: (Document) sb.toString()

Here's a screenshot:

 

And this is presented in IE, the bestest of the browsers:

 

G.

 

 


 

44
Views
0
Helpful
1
Replies