Javascript to cfscript

Hello Gurus
Wondering if this is possible?
(CFMX 5)
I have a cfscript function:
<cfscript>
function doSomething(thingToDo) {
return URLEncodedFormat(Encrypt(thingToDo,myKey));
</cfscript>
takes 'thingTodo', encrypts it with private key and then
makes friendly to use over URLs.
Now I want to pass in a JS variable instead of a raw string,
something like this:
<cfoutput>
<select name="selectObject"
onchange="javascript:location.href='somepage.cfm?#doSomething(this.value)#'">
<option value = "option1">Option 1
<option value = "option2">Option 2
</select>
</cfoutput>
so that thepage forwards to:
somepage.cfm?with_encrypted_js_variable_here
Is there a way to do this?
I have no hair left, so any pointers in the right direction
appreciated
Jam

Not sure if this is what your looking for but... how about
this?
Note: if you want to encrypt the values on the fly you'll
need to encode ( or encrypt ) through javaScript. I beieve the cold
fusion and javaScript are processed and run at different times.
<cfscript>
myKey = 'test';
function doSomething(thingToDo) {
return URLEncodedFormat(Encrypt(thingToDo,myKey));
</cfscript>
<script language="javascript">
function loadURL(str) { self.location.href = 'somepage.cfm?'
+ str; }
</script>
<cfoutput>
<select name="selectObject"
onchange="loadURL(this.value)">
<option value = "#doSomething('option1')#">Option 1
</option>
<option value = "#doSomething('option2')#">Option 2
</option>
</select>
</cfoutput>

Similar Messages

  • Cfscript

    I have a client side button that, when clicked, links to a
    server side page with delete queries. However, I must give the user
    a confirmation message making sure they really want to delete the
    current record. I am attempting to perform this via JavaScript
    within <cfscript> tags. However, I am having some troubles.
    Below is the code....the first part is in the <head> section
    (CR4203.cfm is the server side page with the deletion queries), and
    the button itself is in the <body>. Any ideas how to get this
    working, or a new approach I can take???
    <cfscript>
    function ConfirmDelete() {
    if (confirm("Click OK to Delete this CR.")) {
    window.location="CR4203.cfm";
    </cfscript>
    <cfscript>
    <input type="button" name="Delete" value="DELETE CR"
    onclick="ConfirmDelete()">
    </cfscript>

    This should do it
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
    Transitional//EN">
    <html>
    <head><title>delete test</title>
    <script type="text/javascript">
    function ConfirmDelete() {
    if (confirm("Click OK to Delete this CR.")) {
    window.location="CR4203.cfm";
    </script>
    </head>
    <body>
    <form>
    <input type="button" name="Delete" value="DELETE CR"
    onclick="ConfirmDelete()">
    </form>
    </body>
    </html>

  • Cfscript code assist?

    Hi,
    It would seem that CF builder2 doesnt have any code assisting for cfscripting.?
    Surely ive missed something here.
    If this is the case then im wondering whats going on as DM CC is clearly trying to discourage you from using it for coldfusion (by stripping out previous CF tools).
    CF builder has no code assist for cfscript..
    i like to use cfscript in my components as I like the way it resembles other languages im familiar with, eg javascript, c# etc.
    Im wondering now, why bother, just use the TAGS ank keep life simple?

    @advancesolutionsni: Code assist absolutely does work in script. What is an example of what’s not working for you? especially compared to something that “works” for you in tag syntax?
    For instance, if you maybe want arguments of a function to popup for you, that does work. But do note that (in either tags or script) you need to click ctrl-space to make that work.
    Same with seeing a list of available variables on a page when naming a variable on the right-side of an assignment, or seeing the list of available datasources defined in your CF Admin when creating a query, or seeing the list of CFCs when doing a createobject of a component, or seeing a list of methods in a CFC when referring to an instance of one, and so on.
    BTW, those last four are things that DW never could do, and it just scratches the surface of such differences, so CFB really is much more than just “a different CF editor”. Each does things the other does not. We need to learn to use each tool to its max, and the way it works.
    To that end, I would point out that there is a very substantial user guide for CFB, available online
    http://help.adobe.com/en_US/ColdFusionBuilder/2.0/Using/index.html
    And there’s a specific section on code assist, with more on the above, at:
    http://help.adobe.com/en_US/ColdFusionBuilder/2.0/Using/WS0ef8c004658c1089-554789f8121af8f 0c8c-7ffb.html#WSd160b5fdf5100e8f-1264b51812d55ebda15-7ffb
    HTH.
    /charlie

  • Cfscript. recalculating numbers

    Hello
    I have a database with images. There are 3 columns, one with
    the width, the other one with the height and the last one the name
    of the file.
    I would like now to send width and height to a cfscript which
    recalculates the width/height values - I know this sounds strange
    but I need it for a representation on a website. So note that I
    don't want to resize the oiginal image, I just want to have values.
    I neither want to change anything in the database!
    And I don't need to do that on several images at the time!
    I imagine something like this: <cfset newDimension =
    rescaleImage(503,2004,250,500)>
    where
    'rescaleImage' would be the script
    503 the width coming from my database
    2004 the height coming from my database
    250 the max. width
    500 the max. height
    So the script should check.
    1. whether the dimension has to be resized (if smaller than
    the max. values the output should be the values similar to the ones
    in the database)
    2. whether the width has to be reduced to the max. width and
    the height calculated proportionally to the max. width
    3. whether the height has to be reduced to the max. height
    and the width calculated proportionally to the max. height
    and the output could be a two value list containing width and
    height....
    Does anybody know whether such a script already exists or can
    somebody help me wrting it (what means this somebody would have to
    write it ;-)
    Many thanks
    Actually I could calculate this stuff in Coldfusion with cfif
    and evaluate and so, but I think this is so much code each time. So
    i prefer sending values to a script and get the stuff
    back....

    Hi,
    I don't know if it's useful for you, but I'm always using a
    javascript function to adjust images within a container
    (client-side in the browser).
    cheers,
    fober
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
    Transitional//EN">
    <html>
    <head>
    <title>Untitled</title>
    </head>
    <body>
    <style type="text/css">
    div.image-container{
    border: 1px solid red;
    width:200px;
    height:200px;
    overflow: hidden;
    </style>
    <script type="text/javascript">
    function resize(obj){
    if(obj.height > obj.width)
    obj.style.height='100%';
    else
    obj.style.width='100%';
    </script>
    <div class="image-container">
    <img id="pic1" onload="resize(this)"
    src="sample-300-300.gif">
    </div>
    <div class="image-container">
    <img id="pic2" onload="resize(this)"
    src="sample-100-300.gif">
    </div>
    <div class="image-container">
    <img id="pic3" onload="resize(this)"
    src="sample-300-100.gif">
    </div>
    </body>
    </html>

  • Javascript  - is there something like an "active row count" property??

    Lets say I have a tabular form. Every time I use the form, the # of rows returned by the query will vary. Maybe first time I go to the page, the select statement returns only 5 rows, but the next day it returns 25 rows.
    Is there some type of system variable to stores the # of rows visible on the page at a given time within this tabular form?
    I realize that if I have an tabular form item with an id of f03 for example, then on each row it will be referenced as f03_0001, then f03_0002 on the next row and then f03_0003 on the next row etc...
    In pseudocode, here is what I want to do:
    For i = 1 to ACTIVE_ROW_COUNT (assuming this is the # of rows in the HTML table)
    perform some operation on 'f03_000' + ACTIVE_ROW_COUNT
    Do you see what I'm after? I checked the APEX api, but I couldn't find such a property. It seems like you can't do much if you can't figure out this current index # or the max on the page.
    Also, I tried playing around with the "this" keyword in hopes of finding a pointer to the "current item" that would have triggered the onchange event, but no luck either.
    Thanks in advance.

    Hi:
    Within javascript you can reference the columns of the tabular form as
    <script>
    col1 = document.forms0.f01;  // the first updateable column of your report
    alert (col1.length) ;   //  number of rows
    </script>varad
    Edited by: varad acharya on Dec 8, 2008 5:53 PM

  • Problem with JavaScript in my PDF Form buttons

    I am trying to have my user click on a button in my form on my website and e-mail the form data to me.
    I am using the following JavaScript with my form button:
    this.mailForm(false, "[email protected]", "", "", "Subject", "Message Body");
    Protected mode is off.
    When I use the above statement (whether the 1st parameter is set to true or false), nothing happens – no email gets sent and no mail dialog box appears. If I change from this.mailForm(...) to this.mailDoc(...), I get a mail dialog box but, as expected, it sends the blank form without the filled-in data due to low user privileges.
    How can I send the form data with this.mailForm(...)? (Note that I prefer to use this.mailForm(...) rather than mailto:(...) because this.mailForm(...) supposedly allows me to e-mail the form without user interaction.)
    -- Don

    Thanks for responding.  I have been using “Submit a form” in the Mouse up event.  I had that operation do a mailto: and it worked, but required user interaction on the part of the web page visitor.  I have successfully created an equivalent JavaScript including:
        var url = "mailto:[email protected]?subject=mySubject&body=MyMessage"; 
        this.submitForm(url, true);
    The above sent the FDF file successfully, but again, it required user interaction.
    Then I tried this JavaScript - as I mentioned in a previous post - after you said to use doc.submitForm():
        var url = "http://mydomain.com/submit_notice.php";
        doc.submitForm(url, false);
    The above script seemed to do nothing (with no error message). Shouldn't it bring up the PHP file in the web browser?
    I have that php file, submit_notice.php, created, but I have not written any PHP scripts to e-mail the FDF file.  I have never written a PHP script to take the posted FDF data and email it, but I have used the PHP mail() function and posted variables.
    As for what I want to happen on the client side after the submit takes place: I simply want the FDF file to go to an e-mail that I specify.  Additionally, I need it to happen without any client interaction on the part of the web page visitor.  I can expect that visitor to have Adobe reader, but no add-ons or protected mode requirement.
    Please give me an example that emails the FDF file without any user interaction.
    Thank you.
    -- Don

  • Open and Close Popup With Javascript

    Using Apex 3.2
    I have probably done this loads of times in my old job, but do not have access to the code and today I just can't get it to work properly.
    I have opened a pop up window with javascript
    Now I need to close it and refresh the calling page, but only if it passes the validation on the popup.
    I have a hidden item on my pop up called P7_FLAG.
    I have a page process after validation that sets P7_FLAG to (only set to 1, if passes validation).
    I also have a SUBMIT button.
    So once I click my SUBMIT button the page should look at the validations, if ok, set P7_FLAG to 1, then close the popup and refresh the calling page.
    My current javascript look like this
    <script type="text/javascript">
    function saveChanges(){
    doSubmit('SUBMIT');
    var test = $x('P7_FLAG').value;
    if(test == '1')
    window.close();
    window.opener.doSubmit('REFRESH');
    </script>On my button
    javascript:saveChanges();The problem is that I need to click the SUBMIT button twice.
    First time it sets P7_FLAG
    Second time it closes page and refreshes.
    I have probably made some basic error, but today I cannot see it.
    Cheers
    Gus
    Edited by: Gus C on May 10, 2012 12:48 AM

    <script type="text/javascript">
    function saveChanges(){
    doSubmit('SUBMIT');
    var test = $x('P7_FLAG').value;
    if(test == '1')
    window.close();
    window.opener.doSubmit('REFRESH');
    </script>javascript does not wait for the current action to complete and then perform the next line.
    means in your function call
    doSubmit('SUBMIT');is triggered and it carry on's to next line that is
    $x('P7_FLAG').value;this will not be set because you are setting the value of P7_FLAG to 1 in plsql and trying to check in javascript, which will not work.
    what you need to do is amend your js function like below
    <script type="text/javascript">
    function saveChanges(){
    doSubmit('SUBMIT');
    </script>create a page branch to procedure and make it conditional to when P7_FLAG = 1
    and set the branch source to below
    htp.p('window.close();');
    htp.p('window.opener.doSubmit(''REFRESH'');');

  • It appears to be a javascript problem, but firefox cannot open pages from ebscohost websites.

    I'm a librarian at DePauw University. People who have upgraded to Firefox 5.0 or higher can get to Ebscohost pages but once there cannot do anything. For example, if I am on the Ebscohost Scientific American page and I try to expand +2011 in order to see the 2011 Scientific American issues nothing happens. It looks like javascript is supposed to expand the +2011. Everything works fine in Firefox 3.6.

    When you have a problem with one particular site, a good "first thing to try" is clearing your Firefox cache and deleting your saved cookies for the site.
    1. Clear Firefox's Cache
    Tools > Options > Advanced > Network > Offline Storage: "Clear Now"
    2. If needed, delete the site's cookies here
    right-click a page on the site, choose View Page Info > Security > "View Cookies"
    Remove all cookies on servers ending with sympatico.ca
    Then try reloading the page. If you need to log in to read stories, you probably will have to log in again after removing their cookies.
    Does it help?

  • Adobe Flash & Javascript don't work even though Enabled

    Ever since what I think was either a Firefox upgrade (I don't know which one) or installation of Quicktime, my Adobe Flash Plugin is perpetually crashed and I cannot play any Flash content on any website. All that displays in place of the video is a gray screen with the sad-face Lego icon and the message: “The Adobe Flash Plugin has crashed. Please reload the page to try again.” (See attached image.) But it will not resolve when reloaded.
    No Flash videos on any sites work. HTML5 videos work on YouTube when tested, but non-HTML5 videos won't work.
    Also, my Javascript does not seem to be working since at least some displays requiring javascript don't work. Sometimes the display just doesn't work, and sometimes I get a message that javascript is disabled and must be enabled, but it is already enabled (set to “true” in about:config).
    I have spent days scouring every help forum entry I can find on troubleshooting Flash Player and Javascript. Everything on my end seems to be in order and I cannot find or fix either problem. I think it is possible the issue could have its roots in the fact that Javascript seems to not be working which may be preventing Flash Player content from working...??
    Also, Flash content does work in I.E. but not in Firefox (I do not have Chrome installed so did not test in Chrome). I have too many window tabs open in Firefox and can't switch to I.E. (nor do I like to use I.E.).
    PLEASE HELP as this is crippling for very important work deadlines I have.
    This is what else I know and have tried:
    I have a Toshiba Satellite C75D-A Laptop;
    Processor: AMD A6-5200 APU with Radeon HD Graphics; x64; 2.00 Ghz;
    RAM: 8 MB;
    OS: 64-bit system; Windows 8.1 (but some auto-check utilities detect it as 8.0 because it was upgraded.);
    Graphics Card: “Desktop Graphics” System – AMD Radeon HD 8400 (0x9830);
    Installed Graphics Driver Version: AMD 13.352.1004.1007 (Driver Date: 4/22/2014)
    My Device Manager graphics driver updater states: “driver software is up to date.”
    From the AMD website: the graphics driver auto-detect utility recommended the AMD Catalyst Driver (amd-catalyst-omega-14.12-without-dotnet45-win8.1-64bit.exe) I tried installing this driver, but it won't install. After trying to install, I got a message stating: “We are unable to find a driver for your system.” But Device Manager states I have a current driver, and my graphics card & driver seem to be working fine, so I do not believe this is part of the issue.
    I am using Latest Firefox version 35.0.1; and
    Using Latest Flash Player: 32-bit NPAPI Plug-in Version: 16.0.0.296; designated: “always activate” (Downloaded new update several times, including fresh install after uninstall; system & web address icons indicate Flash is enabled).
    I turned off hardware acceleration in FF Tools>Options>Advanced>General
    I disabled WebGL as explained here: https://support.mozilla.org/en-US/kb/upgrade-graphics-drivers-use-hardware-acceleration
    I am using Ad-Block Plus which has never affected things in the past. I have not tried starting FF in Safe Mode because I believe I will lose all open tabs and not be able to recover them (I may have over 200 open). But disabling add-ons has no effect (I disabled all except for Sessions Manager in case of a crash). (My No-Script has been disabled for at least six months.)
    I have Windows Media Player and Quicktime installed.
    Quicktime is most recent upgrade (7.7.6) so should not be a problem according to:
    “QuickTime plugin takes over Flash” at:
    http://kb.mozillazine.org/Flash#Disabling_Protected_Mode_in_Flash_11.3
    (note underscores in place of spaces in string; underscores not insertable here)
    Disabling Quicktime had no effect in the prior version of FF (ver. 35.0), but in latest FF ver. 35.0.1, Flash videos only display a plain (blank) gray screen instead of the sad-faced icon and crash message.
    (I tried to uninstall Quicktime altogether, but was not able to due to Error codes 2502 & 2503. I tried troubleshooting that as well with no luck using methods successful for other programs, including here:
    http://www.fixkb.com/2014/01/error-2503-and-2502-when-uninstalling-on-windows-8.html;
    & here:
    http://answers.microsoft.com/en-us/windows/forum/windows_8-winapps/re-internal-error-codes-2502-and-2503-for/ba5f2145-aa6e-4cc0-81a7-e4346f43b698.)
    Disabling my FF theme and using the default brought back the sad-faced icon and crash message in the place of videos on some YouTube pages, but not other YouTube pages (where video was still blank gray screen). It also enabled a still Flash image (an ad) to display on a different website page that previously had a Flash Plugin crash message. I have been using this same theme for a couple of years without previous issue. While turning it off did generate an effect on some still imagery, it didn't fix the video problem.
    I tried Disabling Protected Mode in Flash 11.3 as explained here:
    http://kb.mozillazine.org/Flash#Disabling_Protected_Mode_in_Flash_11.3
    (note underscores in place of spaces in string; underscores not insertable here).
    It did not solve the issue.
    I also deleted all storage & data in Flash Player as advised. This had no effect either.
    I've tried all solutions I've been able to find and am at a loss for what to try next. Please help and advise ASAP. Thank you!!

    ''guigs2 [[#answer-684038|said]]''
    <blockquote>
    I truely admire the efforts that have been made to make this work.
    "“We are unable to find a driver for your system.” "
    For it not installing, you need to follow these instructions to install them: see the comments: [http://answers.microsoft.com/en-us/insider/forum/insider_wintp-insider_devices/windows-10-atiamd-display-drivers/50944d10-dde3-4e08-8244-d54eb2b1e7de] --> take warning though it looks like it has caused issues for others as well.
    Since it was working for some youtube videos and not others, there might be an issue with a particular video codec. DO you have OpenH264 Video Codec provided by Cisco Systems, Inc. plugin?
    Is it possible to try Safe Mode after saving your session with [https://addons.mozilla.org/en-US/firefox/addon/session-manager/ Session Manager Addon]? IT would test hardware acceleration in Firefox.
    </blockquote>
    Thank you, guigs2! Sorry for my delayed reply...I didn't realize I hadn't gotten back to you. Update is that I did try a whole slew of other troubleshooting steps including starting FF in safe mode, to no avail. However, I was FINALLY (after months) able to solve this problem just today by pure chance!
    The problem was that hardware acceleration was enabled in the Flash settings. I had not been able to turn it off because I didn't have access to the Flash Player settings as long as the crash error message was visible, which was all the time! Today, by a sheer fluke, I saw a static picture in place of the crash message on a Flash video. I snagged the opportunity to call up the settings and turn off hardware acceleration, and it fixed the problem for my whole browser! This has been a frustrating issue because I did not have access to the settings utility as long as I had the crash message, which was always, so my Flash was crippled without the ability for me to fix it until pure luck gave me this window of opportunity.
    Does anyone know another way to access the settings utility if this ever happens again in the future? I could not find a way. (Incidentally, I had tried disabling hardware acceleration via my graphics driver settings, but it didn't fix the problem.) We need Adobe to allow some other way to access the Flash Player settings utility when this problem arises since they aren't accessible when there is a static crash message.
    Thanks again!

  • Just had Javascript update done and now Firefox won't open,,,keeps coming up with XML Parsing error not well formed. how can I get rid of this?

    also awindow pops up NS error XPC Bad convert JS cannot convert JAVASCRIPT argument arg 4 (NSL window watcher open window)
    == This happened ==
    Every time Firefox opened
    == just today ==
    == User Agent ==
    Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; (R1 1.5))

    There's a lot there, so I'll start with the parts I can answer quickly.
    The "ACL found but not expected..." messages can be safely ignored, so says this article
    http://docs.info.apple.com/article.html?artnum=306925
    (look below all the "SUID" examples)
    I had changed my Desktop image earlier but when the "Installing 1 item" window came up it changed back to the back ground that you first see on your desktop after installation.
    Leopard installs updates a bit differently. If it's simply an application that does not change system files, it installs them like before, without having to restart. If the update is to the system, then you must immediately "restart," It then goes to that stars and purple screen to perform the installation. Before, it would do the installation while you still had control of the Mac and would prompt you to restart when it finished the installation. This change probably make things more secure and reliable, because you aren't allowed to do other things on the Mac while system updates are being installed.
    Please post back with the remaining point of concern.

  • Adding javascript to page open and page close in acrobat 8.1.2

    Reading the Acrobat Javascript Object Specification on page 22 it says that you can add javascript to the "page open" and "page close" events of a document.
    It then says that under the menu "Document -> Set page action" you can add scripts for those events
    I am using Acrobat 8.1.2 and under the document menu there is no "Set page action". And there is nowhere where I can find any "set page action" menu...
    whats the deal?
    How can i set the page open and page close events in acrobat professional 8.1.2?????????????
    Marc

    - open the Navigation Panel 'Pages'
    - select the page and open the page properties
    - in the actions tab you can set the page actions

  • How can we remove javascript completly from J2EE based web application?

    java script produce lots of problem in web application i just want to remove them comletly

    rinku5259 wrote:
    java script produce lots of problem in web application i just want to remove them comletly3 easy steps
    1. using the mouse or keyboard, select the javascript code
    2. press the delete button on the keyboard
    3. save the file
    do that for each file that has JavaScript in it

  • Feature Request: Javascript libraries of which the versions are in better control

    This essentially aimed at the developpers:
    Anyone who browsed with noscript, or used ghostery, knows the web is full of javascript. These are often downloaded from separate websites.(for no apparent reason, they can easily be hosted locally) This is a bad thing:
    * Accessing these gives the the http-referrer(presumably) so it indicates someone where you are browsing.(though other resources do this too)
    * Javascript is nowhere as secure as html in terms of potential weaknesses.
    * Javascript is -plainly- designed to have access to the web page, or the current url.
    * These are often accessed via http, it could be spoofed to return a different
    * The servers it came from can outright change it at any point, and the user has little control, even if the javascript source code unobfuscated, there is no time to do so as it is in the hands of the users immediately.
    For this reason i suggest implementing a library(package system) for these javascripts, of which the packages are signed, and the user controls when they are updated. It should be easy to use and add these libraries for developpers, preferably, additional people can attest they read the source code and approve of it.
    Well, to be honest, i cannot really suggest entirely how to do it, i just dont know enough. And it has to be entirely transparent to users, at least. Some kind system that detects that people have checked the source code, and/or a default time duration.(depending on the package)
    Of course this has to be coordinated with other browsers/standards creation. This sounds hard and it seems like you're already doing a really good job at it.(And at developping FF in general)

    Hi Jasper, to give a specific example, if Firefox were to find a site using a particular version of jQuery then it would instead use a pre-validated copy of that library from a trusted site or from the Firefox program folder?
    I think this would be a complex project, but perhaps an extension developer would consider building it, at least to demonstrate how it could be done?
    This forum is like an emergency room so your suggest may get lost here. You can submit a version to the Input site (Help > Submit Feedback connects you) or on a Mozilla mailing list. Not sure which one would be right for this idea, but you could take a look here: [https://lists.mozilla.org/].

  • I need to add a mileage calculation box to an existing form created by someone other than me. Please help, I am new to javascripting.

    I have the book 'Creating Dynamic Forms with Adobe LiveCycle Designer, but none of the javascript or formcalc script is working. Can someone tell me step-by-step how to go about adding this to the existing dynamic form?
    I added a small table on the existing subform, with the other 2 tables already in the form. This looked like a straight forward project. But, I have not any experience in java script other than googling for script and adding it to Adobe Acrobat fillable forms. So, I am sure I am going at this wrong.
    Respectfully

    Hi,
    can you provide the script you have tried and what exactly you want to do. What is the calculation you are trying to do?

  • Assigning a java value(filepath) to a javascript variable

    I have a JSP where I have a java variable(obtained from session) which is nothing but a filepath(say C:\superb.xpdl). When I try to use the variable in javascript using var scriptVar = "<%= sessionVar %>";, the sessionVar value i.e. the filepath is getting modified (like C:superb.xpdl). Slashes are interpredted in a different way(\t for tab, \n for new line etc.,) How to get the filepath with no modifications while assigning to javascript variable? will encoding(using escape()) and decoding help?

    unfortunately you need to double up the slashes
    maybe this will work
    scriptVar = "<%= sessionVar.replaceAll("\\", "\\\\") %>";
    or maybe it will cause a infinite recursion problem (i'm too lazy to try it)

Maybe you are looking for