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)

Similar Messages

  • Its illegal to assign a XML value directly to the messageType variable

    I was recently working in JDeveloper 11g (11.1.1.7.0)  on an internal SOA project making some changes in the BPEL and noticed this message: Error(172): its illegal to assign a XML value directly to the messageType variable "InvokeFetchUpdatedUserId_FetchUpdatedUserID_InputVariable" I searched for this error message and didn't find anything.  The message is somewhat explanatory but I thought I would post the fix here just in case.  I modified my assign from the following:                                                                                                                           To this making sure to assign it to the underlying entity.                                                                                                                           Then it compiled just fine. Thanks, Tom

    In case if you are returning multiple value or with multiple columns then you have to use record or cursor to do that operation.
    satyaki>
    satyaki>ed
    Wrote file afiedt.buf
      1  declare
      2       cursor c1
      3       is
      4         select *
      5         from emp;
      6       r1 c1%rowtype;
      7     begin
      8       for r1 in c1
      9       loop
    10         dbms_output.put_line(r1.empno||' - '||r1.ename);
    11       end loop;
    12*   end;
    13  /
    7521 - WARD
    7654 - MARTIN
    7788 - SCOTT
    7839 - KING
    7844 - TURNER
    7876 - ADAMS
    7900 - JAMES
    7902 - FORD
    7934 - MILLER
    7566 - Smith
    7698 - Glen
    1 - boock
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:01.02
    satyaki>
    satyaki>
    satyaki>Regards.
    Satyaki De.

  • Java code based on a javascript variable

    Hi,
    Based on click of a either linkA or linkB I set a javscript variable (say vA or vB).
    After this I reload the browser.
    My page on the browser in a jsp which gets texts from a properties file (say prop.properties).
    But now based on vA or vB I wish to load vAprop.properties or vBprop.properties.
    I know I cannot access javascript variables in Java code. Please let me know a work around for this.
    I need it very badly.
    Thanks in advance.

    Have your javaScript open the link with a parameter
    yourFile.jsp?param=A
    yourFile.jsp?param=B
    in your JSP do a
    request.getParameter("param");
    You can also use javaScript to post the values if you dont want them to appear in the URL.

  • Assigning a specific value to the sapscript counter variable

    Hi all,
    I am trying to use the sapscript counter variable in my sapscript but encounter the following warning.
    My code looks like the following:
    /: DEFINE &SAPSCRIPT-COUNTER_0& = 0
    The new counter value is &SAPSCRIPT-COUNTER_0(+)&
    The warning i get when i do the syntax check is:
    Ambiguous symbol &SAPSCRIPT-COUNTER_0&
    What is wrong with my syntax?
    Appreciate any help i can get.

    Hi,
         If i am not wrong you are trying to reinitializing that standard variable. if that is the case one thing, in script we cannot assign values to variable other than at initializing time but here you don't have chance to initialize that variable because that is standard one. More over modifications to standard variable will give some warnings.
    So try to use other than standard one as per your requirement.
    Hope this will help you.
    Regards,
    Aswini.

  • Assigning javascript variables to java variables in JSP

    Does anyone know if it possible to assign a javascript value to a java variable in a javascript function? I want to be able to use the javascript value in a PreparedStatement call, but I can't assign the value of the javascript variable to a java variable. I know the opposite can be done using hidden variables in the form, but I need:
    javascript -> java variable in a JSP scriptlet.
    Any help would be much appreciated,
    Thanks,
    -Dave

    Can't do that.
    html/javascript is in the client side.
    jsp is in the server side.
    In order to put html/javascript values (client side) into jsp (server side) it must be submitted.
    Try remoting. Using an iframe with a jsp as the source of it and the html target pointing at it.
    -------------

  • Assign a Javascript variable value to a ABAP variable

    Hi,
       I wish to assign a javascript variable value to  a ABAP variable. Any ideas how to do that?
        Many thanks.
    Rgds,
    Bernice

    Here's another suggestion for you.
    BSP Application: SBSPEXT_HTMLB
    Check out the radionbuttongroup.bsp
    So then instead of using a standard HTML radio buttons you can use the HTMLB element with the parameter for onClick set then in your DO_HANDLE_EVENT you can read the value.
    VIEW
    <htmlb:radioButtonGroup id="radio">
      <htmlb:radioButton id="id_link"
                       text="Link"
                    onClick="myClickHandler"/>
      <htmlb:radioButton id="id_unlink"
                       text="Unlink"
                    onClick="myClickHandler"/>
    </htmlb:radioButtonGroup>
    DO_HANDLE_EVENT
      DATA:   lt_event        TYPE REF TO if_htmlb_data.
      lt_event = cl_htmlb_manager=>get_event_ex( request ).
      if lt_event IS NOT INITIAL.
        if  lt_event->event_name = htmlb_events=>radiobutton.
           case lt_event->event_id.
            when 'control_id_link'.
              schalter = ' '..
            when 'control_id_unlink'.
              schalter = '1'.
           endcase.
        endif.
      endif.
    There is an example of how to use it and read it in the DO_HANDLE_EVENT you then just have to pass the variable around (in this example the variable name is schalter and is defined as char1 in the class)

  • Passing struts-tag value to java / javascript variable in JSP

    Hello all,
    Im trying to pass the value got from the struts-tag to the java variable in the Jsp. However Im not able to get the o/p. Can u guys help me on this pls...
    <logic:notEmpty name="TreeBean" property="list">
        <logic:iterate id="Type" name="TreeBean" property="list" indexId="i">
         <br/><bean:write name="Type" />
        </logic:iterate>
    </logic:notEmpty>Here the list can be populated in the jsp page. However i want the values into jsp list. Im not able to populate the same..
    <% List jspList = null;
    %> I want the values into the jspList variable for further processing. Can u guz pls help me on this....

    Which do you want it in?
    A java variable for use in <% scriptlet code %> or a javascript variable for use on the client end?
    scriptlet:
    <jsp:useBean id="TreeBean" type="java.util.List" class="java.util.ArrayList" scope="?????" />
    Having scriptlet code on the page is considered bad coding style.
    What is it you are trying to accomplish by making the value accessible?
    What are you trying to do in java / javascript that can't be done with JSP tags?

  • Assigning values to a javascript variable

    Hi,
    Using request dispatcher, i'm forwarding the control to a html from a servlet like this(obj.forward(/index.html?field1=value1&field2=value2).
    In the receiving end, ie., in the html i would like to assign those 2 field1,field2 values to a javascript variables. Javascript located in the index.html.
    I don't know how to do this.
    Pls any one help me to get of this pblm
    Thanks in Advance
    Kannan.T

    Hi thanks for ur reply,
    You r telling while forwarding a request from one
    servlet to another servlet, we can't add query
    string(requestparameters). But then how come this
    code is working?
    RequestDispatcher
    rdis=getServletContext().getRequestDispatcher("/MyServ
    let?type=normal");
    rdis.forward(req,res);Well I owe an apology here - I was not completely correct. I have tested and found that you can indeed add parameters that way. The catch is that these parameters are nested to that forwarded /included resource. It is not available in the original jsp or to some other resource included from the original jsp unless ofcourse you add the parameter again.
    >
    please give me a solution.
    Like this i have to forward my request (with
    querystring) to a html page.
    That htmlpage should receive parameters and assign
    the values to a javascript variables.
    how can i achieve this.
    thanks in advance.My original reply stands.
    You cannot do that in a html page. You have to have a jsp that generates the html.
    ram.

  • How to assign a JSP variabl's value to a JavaScript variable?

    Hello,
    I want to assign a JSP variable's value to JAVASCRIPT variable.
    or how to assign JavaScript variable's value to JSP varialbe
    HOw do i do it ?
    can anyone please help?
    Regards and thanks for your time.
    Ashvini

    I want to assign a JSP variable's value to
    JAVASCRIPT variable.
    var jsVariable = <%=someVariable%>;
    or how to assign JavaScript variable's value to JSP
    varialbeYou can't. JSP is server-side and JavaScript is client-side. The JSP variables are never available on the client side for any sort of assignment.

  • I want to assign the value of a Javascript variable to JSP Variable

    I want to assign the value of a Javascript variable to JSP Variable .. for example :
    <%
    Bla Bla Bla
    %>
    <script>
    var JavaScriptVariable="hello"
    </script>
    <%
    String JSPVariable=// The Value of JavaScriptVariable ;
    %>
    How can i do that ??
    Thanks

    >I want to assign the value of a Javascript variable to JSP Variable
    cannot be done.Friend try to understand concepts properly Javascript is always excuted by the browser @clientside where as JSPCode is executed Websever(ServletContainer) @serverside.Through you are combining JSP Code blocks(Tags,Expressions,scriptlets...) & javascript under a single page webserver can only identify what is their under JSP Code blocks.
    Hope this could be an appropriate answer for your question.
    However,you can as well submit a request by encoding your URL with request parameters and the submit to the page and then collect it using request.getParameter(name).
    But under a single context state it is not possible
    REGARDS,
    RaHuL

  • Javascript calling Java value

    Hi,
    I've got a slight problem on my JSP page.
    I have a value thru a value,
    request.getParameter("adcomments");I'm trying to call it via javascript in an input value like the following:
    <input name="activate" type="radio" value="3" onClick="document.getElementById('reasondeny').style.display='';document.form1.adm_noapproval.value='"+admconts+"';">I've also set the value in a script tag up the page, referencing the variable as
    <script language="javascript">
      var admconts = "";
      admconts += admconts + <%=admcomments%>;
    alert(admconts);
      </script>With everything I've tried so far, I've gotten a mixture of unterminated string literal errors and this type of error:
    Error: missing ; before statement
    Source File: http://10.244.212.97:8080/murach/chngctrl/change_ctrl_admin5b.jsp?primID=3181
    Line: 405, Column: 41
    Source Code:
    admconts += admconts + 1/26 - Submit to Default Audit for gap analysis, due 2/2.  
    any ideas on where I'm going wrong? Any feedback would be appreciated. Unfortunately the other posts regarding similar javascript issues weren't able to help me solve this.

    Unfortunately the other posts regarding similar javascript issues weren't able to help me solve this.If you've read the other posts, then you've probably seen this answer before.
    Java is not Javascript. The two can't communicate or share variables directly.
    Java/JSP runs on the server, produces an HTML page, and stops running.
    Javascript starts running in your browser when/as the page is loading.
    You can not communicate directly between the two.
    To run java again, you have to send a new request (submit a form, click a link, make an Ajax call)
    What you CAN do in the JSP is produce javascript code onto the html page that will be run when in the browser. So you can create basic javascript variables that get their initial value from java/jsp.
    // java code declaring a variable
    <%  String adcomments = request.getParameter("adcomments"); %>
    <script language="javascript">
    <!--
    // javascript code declaring a variable.
      var adcomments = "<%= adcomments %>";
    //-->
    </script>Say that you run this code, and pass a value of "This is my comment" as the parameter.
    Java would run, retrieve that parameter, and then generate an HTML page like the following
    <script language="javascript">
    <!--
    // javascript code declaring a variable.
      var adcomments = "This is my comment";
    //-->
    </script>Thats as close as you can get to java/javascript communication.
    Note that it doesn't directly copy the value, just generates the value onto the page. You have to ensure that it is valid javascript.
    If your parameter has characters like quotes, newlines etc etc, then that may result in a javascript syntax error. A function to escape javascript characters like that is normally called for. ie replace newlines with \n, and quotes with \"
    Hope this helps,
    evnafets

  • How can I assign javascript variables to jsp or java variables.?

    How can I assign javascript variables to jsp or java variables.?

    See I have generated some variables in the javascript which is on the jsp page. I want to assgin these variables to the jsp vaiables. Or how can I access javascript variables from jsp on the same jsp page.

  • How we can assign resultset variable to javascript variable

    can any1 plsss
    i want to assign resultset variable to javascript variable but it diagnosis some mesg like that
    type can not resolved"
    my code as follows
    <%! ResultSet al=(ResultSet)request.getAttribute("mydata");%>
    <script language="JavaScript">
    <%--<% ResultSet al = (ResultSet)request.getAttribute("mydata");%>--%>
    var alm=<%=al%>
    function pass()
    while(alm.next())
    document.write(document.myApp.dataValidation(alm.getString("Login")));
    document.write(document.myApp.dataValidation(alm.getString("Passwd")));
    document.write("<br>");
    </script>
    <jsp:plugin type="applet" code="TestApp.class"
    name="myApp"
    codebase="http://localhost:8080/dbServlet/"
    width="600"
    height="80">
    </jsp:plugin>
    <input type="button" value="Click me!"
    onclick="pass()" >

    double post http://forum.java.sun.com/thread.jspa?threadID=5245891&tstart=0

  • How to get real value from selectOneChoice with javascript?

    Hi,
    How to get real value from selectOneChoice with javascript? The event.getNewValue() only gets me the index of the selected item, not the value/title.
    JSF page:
    <af:resource type="javascript">
    function parseAddress(event)
    alert("new value: " + event.getNewValue());
    </af:resource>
    <af:selectOneChoice label="Location:" value="" id="soc4">
    <af:clientListener type="valueChange" method="parseAddress" />
    <f:selectItems value="#{Person.locations}" id="si7"/>
    </af:selectOneChoice>
    HTML :
    <option title="225 Broadway, New York, NY-10007" selected="" value="0">225 Broadway (Central Office)</option>
    <option title="90 Mark St., New York, NY-10007" value="1">90 Mark St. (Central Office)</option>
    Thanks a lot.

    Something I was missing ,
    You need to add valuePassThru="true" in your <af:selectOneChoice component. I have personally tested it and got the actual value in alert box. I hope this time you got the real solution. You can also test the following code by your end.
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <af:document id="d1">
    <af:form id="f1">
    <af:panelBox text="PanelBox1" id="pb1">
    <af:selectOneChoice label="Set Log Level" id="soc1"
    value="#{SelectManagedBean.loggerDefault}"
    valuePassThru="true">
    <af:selectItem label="select one" value="First" id="s6"/>
    <af:selectItem label="select two" value="Second" id="s56"/>
    <af:clientListener method="setLogLevel" type="valueChange"/>
    </af:selectOneChoice>
    <af:resource type="javascript">
    function setLogLevel(evt) {
    var selectOneChoice = evt.getSource();
    var logLevel = selectOneChoice.getSubmittedValue();
    // var logLevelObject = AdfLogger.NONE;
    alert("new value is : " + logLevel);
    //alert(evt.getSelection);
    //alert(logLevelObject);
    evt.cancel();
    </af:resource>
    </af:panelBox>
    </af:form>
    </af:document>
    </f:view>
    </jsp:root>

  • How can i assign a Javascript variable to JSP variable

    Hi guys
    how i can assign a javascript variable to jsp expression.,
    e.g.,
    <input type = "button" value = "Add more" onclick = "return submitform1('<%=s%>')">
    function submitform1(String s)
          var s1 = s
    document.form1.action = "../intimation.do";    /* Here i want to pass the value s1 to jsp or servlets without using hidden fields and Query string*/
           document.form1.submit();
          return false;
    /*  i want to pass the values thru session whether it is possible */
    pls give sample code
    Reply
    Marimuthu

    You don't have the session.
    All you have is HTTP.
    The only way to communicate from the client to the server is via an HTTP request. The only way to send a value like that is with a parameter.
    Using a form with method="submit" as mentioned will pass the parameters without displaying them in the url bar (is that what you wanted?)

Maybe you are looking for

  • Unbalanced InstanceBegin Tag.......please help

    I tried to put in a new advertisement in the coding and obviously I deleted or added something i don't know.  I honestly have little experience.  IF anyone can help me solve this problem it will be much appreciated. "There is an error at line 2 of...

  • Java Newbie Question - the import statement

    Hi Geeks, I have a problem for importing a java .class in my project. This latter is named "Tedetis_New". Inside it, I created a "src" folder containing all the source code of the application. I import a jar file inside the parent directory of "src"

  • How to subsequently change ERROR_ON_OVERLAP_TIME parameter in PL/SQL?

    Hi All! I have a problem considering the ERROR_ON_OVERLAP_TIME session parameter. I would like to change it from the inside of a PL/SQL block. It simply works this way: DECLARE BEGIN EXECUTE IMMEDIATE 'ALTER SESSION SET ERROR_ON_OVERLAP_TIME=TRUE'; E

  • Save Select List states and load it on reload

    Hi all, I have a form in which the user have to choose the values from 5 Select Lists connected with LOVs. If the user selects values in the first 3 lists, but in the fourth one the value which he/she looks for does not exist, the user clicks on a li

  • RFQ Related Question

    How to  prevent one RFQ being converted in several PO's ?