| Author |
problem in including jsp custom tags in javascript functions
|
srinu reddy
Greenhorn
Joined: Oct 21, 2007
Posts: 12
|
|
Hi I am having problem while passing jsp custom tags tp javascript. The problem is Unterminated string literal. please, help me out the code is something like this <script> show('<adc:get name="SigningMode" />'); toggleSigningConfig('<adc:get name="SigningMechanism" />'); </script> Thanks & Regards srinu reddy [ March 07, 2008: Message edited by: Bear Bibeault ]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56175
|
|
|
If any of the values emitted by the custom tags contain un-escaped quote characters, of course you are going to run into trouble. Your tags will need to make sure that any value that they emit are properly escaped for use as JavaScript string literals.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
srinu reddy
Greenhorn
Joined: Oct 21, 2007
Posts: 12
|
|
it returns string literal how to deal with. the converted servlet code is something like this out.write("<script>\r\n"); out.write("show('"); if (_jspx_meth_adc_get_1(_jspx_page_context)) return; out.write("');\r\n"); out.write("toggleSigningConfig('"); if (_jspx_meth_adc_get_2(_jspx_page_context)) return; out.write("');\r\n"); out.write("</script>\r\n"); the above piece of code is converted servlet giving problem , then how to deal that. regards srinu
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56175
|
|
Your tag is emitting script that you then put inside a JavaScript string literal? Surely you can come up with something less convoluted? In any case, if what your tag is emitting text that is to be embedded inside a JavaScript string literal, it must ensure that all quote characters are escaped with \.
|
 |
srinu reddy
Greenhorn
Joined: Oct 21, 2007
Posts: 12
|
|
my tag is emmiting text. i tried with \(escape sequence) but not working. still it is saying unterminated string literal. script is here.... <script> show('<adc:get name="SigningMode" />'); toggleSigningConfig('<adc:get name="SigningMechanism" />'); </script> generated servlet code for the above is here............ out.write("<script>\r\n"); out.write("show('"); if (_jspx_meth_adc_get_1(_jspx_page_context)) return; out.write("');\r\n"); out.write("toggleSigningConfig('"); if (_jspx_meth_adc_get_2(_jspx_page_context)) return; out.write("');\r\n"); out.write("</script>\r\n"); javascript error is here ..... Unterminated String literal show('Attended.... I think it is not finding the ending quote properly. As you doubted in the previous reply it is only emitting text (either Attende or Unattended). please, suggest me a solution for the above. Regards, srinu reddy etta.
|
 |
Brent Sterling
Ranch Hand
Joined: Feb 08, 2006
Posts: 948
|
|
Is adc:get a custom tag that you wrote (or at least have the source code for)? It sure seems like the issue is with what the custom tag is returning. I cannot say I have looked much at generated servlet code for custom tags. What would cause either of those return statements to execute? That path sure seems like it would result in an unterminated string. - Brent
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56175
|
|
|
Showing us the unprocessed tags is not useful. Do a View Source in the browser and you will see what is being returned to the browser so that you can figure out what's not being formatted correctly.
|
 |
 |
|
|
subject: problem in including jsp custom tags in javascript functions
|
|
|