sefirosu
sefirosu

Reputation: 2648

how to skip % sign on jsp?

here is the code, i want all space string to be replaced by '%20':

the problem is... its html source displays like this ->

it is currently skipping all my '%' signs... and what I expected to get is something like this (the 'TOP%20NAV' is hard code, ignore it plz) -->

=====================================================================================

here s the code producing the url:

any suggestions? thanks

Upvotes: 0

Views: 1182

Answers (3)

Woodifer
Woodifer

Reputation: 1019

First, I think Balaji's solution might be the way to go, however here is another option.

I have run into this same issue before and ended up using the html entity in place of the % sign. For example:

<c:set var="level1PageTitleFormat" value="${fn:replace(level1Page.title,' ','&#37;20')

This should get the job done for you.

Upvotes: 0

Balaji Natarajan
Balaji Natarajan

Reputation: 202

Please use

<c:out value="${title}"/>

This will HTML-encode the string.

Upvotes: 0

Ivaylo Strandjev
Ivaylo Strandjev

Reputation: 70989

In strings when formatting replace single % with double %% to escape the percent sign.

Upvotes: 2

Related Questions