Write string with quotes in c:out vaue? - string

I want to write a string with quotes in a jsp page which is using jstl tag c:out for its value that means I want to write:
c:out value = '"4"'
Please suggest asap..

Did you try to use escapeXml attribute?
<c:out value='"4"' escapeXml="false"></c:out>

Try this.
<c:out value='\\"4\\"'/>

Related

How to use quotation mark in EL Strings?

I get the Error: EL Expression Unbalanced while trying to add quotation mark in EL String. How can I do that?
#{chainModel.selectedChain.equalsIgnoreCase("")
? 'Kettenbearbeitung' :
'Verkettung'
.concat('"')
.concat(chainModel.selectedChain)
.concat('"')}
Try to use \" ASCII HTML Names to avoid JSF Syntax validations when you need to concat JAVA values with complex strings. Or use \" for double quotes or \' for simple quotes and it will be simplified when you need for a simple string.
In your case I propouse the following:
? 'Kettenbearbeitung' :
'Verkettung'
.concat('\"')
.concat(chainModel.selectedChain)
.concat('\"')

Firebug identified xpath not working in protractor

Firebug identified xpath not working in protractor.I ahve cretaed xpath using firebug.When I identify the xpath using IDE,it is working fine.However when I use the same xpath in protractor,it is not working.My element does not have id or name.So here i can use only xpath option.
Please find the below image for reference.
Here I need to verify whether that particular element has "IRCTC Attractions" text.
Could you please help me?
HTML code:
//div style="width:100%;" class="g_hedtext">IRCTC Attractions /div
Find the element by text and assert it's present:
var elm = element(by.xpath("//div[. = 'IRCTC Attractions']"));
expect(browser.isElementPresent(elm)).toBe(true);
OK, looking at your error message (in the comment):
Exception loading: SyntaxError:
C:\Users\XXXX\AppData\Roaming\npm\TC_model2.js:7
var disclaimermessage = element(by.xpath('//[#id='disclaimer-message']'));
^^^^^^^^^^ Unexpected identifier
(I'm guessing where the carets before "Unexpected identifier" were aligned. Is that right?)
The problem is that you've used single quotes both to delimit the string 'disclaimer-message', and to delimit the whole XPath expression '//[#id='disclaimer-message']'. Thus it appears to the parser that your XPath expression is the stuff between the first two single quotes: '//[#id=', and then the disclaimer-message is some other identifier without any comma or other operator to show what it's doing there.
The solution is to use double quotes inside the XPath expression. XPath accepts either single or double quotes; it doesn't care, as long as you match them with each other. So change the offending line to
var disclaimermessage = element(by.xpath('//[#id="disclaimer-message"]'));
And you should be good to go.
For future reference, this question would have been quicker and easier to answer if you had told us about the error message in the first place.

Jade, how to escape hash character?

I have the following line in my Jade template:
img(src='#{similarArtist.image[0].#text}')
Do not ask me why Last.fm guys decided it was a good idea to use a name starting with hash in JSON document, but this is what I am dealing with.
It seems the 2nd hash sign trips up Jade. Maybe it expects two braces afterwards? I have tried prepending it with a backslash character (traditionally an escape operator) but that did not help.
So what can I do in this case? I really need to access that #text property.
The # is not allowed in dot notation but you can use array notation for that. You can simply do:
img(src='#{similarArtist.image[0]['#text']}')
Not very beautiful solution but it works:
!= '<img src=' + similarArtist.image[0]['#text'] + '>'

JSF 2.0 EL #{param.XXX} dynamic?

Is there a way to fetch params in the .xhtml dynamically?
the normal way would be: #{param.PARAMETERNAME}
now this PARAMETERNAME sometimes not certain and can change.
Is there a way to make e.g.:
{param.#{id}}
i tried it with additional ui:param like
but #{param.paramname} doesn't work... (returns always null like it searches for the absolute "paramname")
The brace notation ([]) was introduced for this very reason. So, if you have a paramName parameter then the following will do the trick:
#{param[paramName]}

How to write a hardcoded string value inside EL expression #{ } in JSF?

I am trying to do the following:
rendered="#{billBean.company.equals("something")}"
But the problem is I cannot write "something" inside #{}. It causes the below XML parsing error:
Element type "h:commandLink" must be followed by either attribute specifications, ">" or "/>".
How can I achieve this?
Use single quote (') to refer to a plain String inside EL:
rendered="#{billBean.company.equals('something')}"

Resources