Javascript & jsp

usually we pass values from jsp to javascript. similarly is it possible to pass values from javascript to jsp. if yes, how?. i'm not asking about return value.

1. you can use ajax
2. submit the page so you can process the request on the server

Similar Messages

  • Online materials for learning Javascript, JSP and EJB

    I am a core java programmer, not aware of J2EE stuffs. Please let me know the best online resources for learning Javascript, JSP and EJB
    Thanks,
    Gautam

    http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/EJBConcepts3.html
    http://otn.oracle.com/sample_code/tech/java/codesnippet/j2ee/ejbbestpractices/ejb-best.html#pattern
    http://java.sun.com/webservices/docs/1.0/tutorial/doc/JSPIntro.html
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html
    http://home.cogeco.ca/~ve3ll/jstutor5.htm
    http://www.pageresource.com/jscript/j_a_02.htm
    I think will do

  • Problem with javascript jsp

    Hi,
    I am using following htl in my jsp.
    <INPUT type=CHECKBOX name='markets' value='911|6' >
    I am using the following javascript in on submit event
    alert(document.form.markets.length );But i am getting "undefined" in my alert box.However if there are more such checkboxes named market...i am getting the length as output.
    what may be the problem?
    Thanks
    Vivek

    i tried this and its working fine:
    alert(document.forms[0].markets.length );
    <form>
    <INPUT type=CHECKBOX name='markets' value='911|6' >
    <INPUT type=CHECKBOX name='markets' value='911|6' >
    <INPUT type=CHECKBOX name='markets' value='911|6' >
    <INPUT type=CHECKBOX name='markets' value='911|6' >
    <INPUT type=CHECKBOX name='markets' value='911|6' >
    <INPUT type=CHECKBOX name='markets' value='911|6' >
    </form>

  • Javascript & JSP - prompt for user name

    I want to prompt the user for their name at the beginning.
    Then I want to save that value in the JSP session because eventually it will be saved along with a bunch of other information into a database table.
    How can I get the JSP session attribute to save the user's input from a Javascript prompt?

    Oh, so
    the javascript part
    name = prompt('USERNAME',' ');
    Can't interact with JSP
    <%
    String user =
    session.setAttribute("userName", user);
    %>
    That's what I want to know how does the
    user = name
    So I guess maybe a regular form would be better for what i need?

  • Plz Help(Reg javascript & jsp)

    hi all
    I am new to java .i strcked in one situation.
    in appl, i used scriptlet code in javascript.
    can i write script let code in javaScript.there is any prob,while writing sciptlet code in javascript.
    i posted my code here .plzz help me.
    function sendvalues(firstinstall){
    var installmentfee = new Array();
    <!--installmentfee is an array to store resp installment fees-->
    <%
    for (int j = 0; j < al.size(); j++) {
    InstallmentVO insVo = (InstallmentVO) al.get(j);
    %>
    installmentfee[0]=firstinstall;
    installmentfee[<%=j+1%>] ="<%=insVo.getTotalFee()%>";
    alert(installmentfee[<%=j%>]);
    <%}%>
    alert(installmentfee[2]);
    var val = document.form.money.value;
    <% int k=0;%>
    while(val>=0) {
    alert("k"+<%=k%>);
    if(val>installmentfee[<%=k%>]){
    val=val-firstinstall;
    document.form.installamount<%=k%>.value = (firstinstall);
    bal=0;<% k++;%>
    }else{
    document.form.installamount<%=k%>.value = (val);
    bal=(firstinstall)-(val);
    val=-1;<% k++;%>
    document.form.balance0.value =bal ;
    if(document.form.balance0.value<=0){
    document.form.FullPaid0.value = 'Y';
    else{
    document.form.FullPaid0.value = 'N';
    document.all['Layer1'].style.visibility = "visible";
    return false;
    plz help me.

    can i write script let code in javaScriptNo you cannot use scriplet code in a java script,
    scriplets are only used in JSP files.
    Kind Regards
    WernsScriplets are only used in JSP files.
    But OP's question was - can i write script let code in javaScript?
    According to my understanding, its possible. Yes, we can write scriplet codes in java script as below
    <html>
    <head>
    <title>Scriplet tags in Javascript</title>
    </head>
    <script>
    function foo(){
         <%System.out.println("Scriplet tags in Javascript");%>
    </script>
    <body>
    <form name="index" onSubmit="index.jsp" method="post">
    <input type="submit" name="submit" value="Submit" onClick="foo()">
    </form>
    </body>
    </html>and, U cant use scriplet tags in a javascript file(js file)
    Am I correct? Comments pls....
    Cheers.
    Message was edited by:
    astelaveesta

  • Applet/Javascript/JSP Communication

    I have defined the following for applet/javascript communication in my applet class
    JSObject topWindow;In my init() method I initialised topWindow as follows
    topWindow = JSObject.getWindow(this);I wrote this call to javascript in my applet destroy method.
    String userDetailsString[] = {String.valueOf(userCount), String.valueOf(userNumber)};
    topWindow.call("closeWindow", userDetailsString);My javascript method is as follows in my html page which has the applet
    function closeWindow(args)
               var userCount = args[0];
          var userNum = args[1];
          var filename = "http://localhost:7001/decrement.jsp?userCount="+userCount+"&userNum="+userNum;
          win1 = window.open(filename,'Logoff',config='height=100,width=200,toolbar=0,scrollbars=0,resizable=0,left=300,top=75');
       }This decrement.jsp call is a file on Weblogic and its supposed to decrement the value of userCount for the UserNum using a sql update query which are passed from the applet to javascript and then to this jsp.
    When I close the browser which should call the destroy method in the applet nothing happens and my javascript is not triggered. I do have MAYSCRIPT in my applet tags and also have the MAYSCRIPT as a param with true as its value within applet tags.
    Where am I going wrong and also have I used the args variable in my javascript correctly to retrieve the values from the applet into the javascript?
    Thanks

    Try to use window.eval("..") That could help sometimes!

  • SERVELT + JAVASCRIPT + JSP ---- Problem

    Hi Java People,
    I have one servlet , few JAVASCRIPTS, one JSP page.
    First when I login some processing is done at back in servlet and some variables are set. after login i enter into main JSP page which contains some BUTTONS. On click of every button I have some JAVASCRIPT calling. Till this stage my work is running fine...........Problem starts now........ that I want to get values in JAVASCRIPT files, which are set in Servlet...........So just tell me how to get information fron there.....
    waiting for reply.........
    T

    <script>
    function called()
    document.form1.your_element.value == "<%=request.getAttribute("attribute")%>"
    </script>
    use scriptlet closed in double quotes....
    you can assign the values directly in the Java Script based on the where you have set your values in servlet..i.e in response,session,request.
    Please try this way..this worked for me.

  • Call jsp function in javascript without using Applet

    anyone knows how to call jsp function in javascript .
    just as follows:
    <%!
    public string jspcall()
    return new String("just a example");
    %>
    <script language="javascript">
    <!--
    temp = jspcall();
    //->
    </script>
    it's desn't work.
    any suggestion will help!

    it's was not able to call a jsp function in javascript.
    jsp function was on server site while javascript normally on the client site.

  • How do i get the selected index in jsp from a select "in the same page!!!"

    i dont if it si possible but i want to get the selected index form a select implmenting javascript jsp an html something like this:
    html:select property="slcLocation" onchange="updateList(this.form)">
    <% for (int i=0; i< user.getNumLocaliza();i++)
    out.println("<option selected>" + user.getLocation(i,1));
    %>
    </html:select> </div></td>
    ...

    i try it in the same page but it fails, the code is:
    <html:select property="slcLocation" onchange="document.location.href='cajaApertura.jsp?slcLocation='+this.options[this.selectedIndex].value">
    <%
    for (int i=0; i< user.getNumLocaliza();i++)
    out.println("<option>" + user.getLocation(i,1));
    %>
    </html:select>
    </div></td>
    </tr>
    <tr>
    <td><div align="left"><font size="1"><strong><font color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif">Caja:</font></strong></font></div></td>
    <td bgcolor="#C4B4F3"><div align="center">
    <html:select property="slcCaja" onchange="document.location.href='cajaApertura.jsp?asdf='+this.options[this.selectedIndex].value">
    <%
    int caja;
    if (request.getParameter("slcLocation")!=null)
    //for (int i=0; i< cajaLocation.getNumCajas (request.getParameter("slcLocation"));i++)
    for (int i=0; i< 3;i++)
    caja = i+1;
    out.println("<option> Caja p " + caja + request.getParameter("slcLocation"));
    }else
    for (int i=0; i< cajaLocation.getNumCajas (user.getLocation(0,1));i++)
    caja = i+1;
    out.println("<option> Caja " + caja);
    %>
    </html:select>
    is this correct? what is my mistake?
    tnks for your help

  • In .java add elements to .jsp

    Hello!
    I'm just beginning and can't understand one thing:
    When I create JSPDynPage, system create JSP and JAVA file - it's clear. Then I add elements to form in JSP, for example, Layout.
    Can I add, for example, row into that Layout in .java file?
        .JSP:
    <hbj:form>
             <hbj:formLayout
                 id="myLayout"
                 width="100%">
                 <hbj:formLayoutRow
                         id="Row1">
                         <hbj:formLayoutCell
                                 id="Cell11"
                                 align="LEFT"
                                 width="100%">                
                                 <hbj:textView
                                     id="welcome_message"
                                     text="May the force be with you unknown user"
                                     design="HEADER1" />
                           </hbj:formLayoutCell>
                   </hbj:formLayoutRow>                      
               </hbj:formLayout>            
        </hbj:form>
    .JAVA:
    public void doProcessBeforeOutput() throws PageException {
             this.setJspName("myjsp.jsp");
          Form Reg_Form = null;
          FormLayout RF_All  = new FormLayout();
          Tray Left_Tray1 = new Tray("TrayRules1");
           Reg_Form = (Form)this.getForm();
           RF_All = (FormLayout) this.getComponentByName("myLayout");
           for (int i = 1; i <= 3; i++ ) {     RF_All.addRow(); }
           Left_Tray1.setTitle("Sample Title");
           Left_Tray1.setWidth("100%");
           TextView Left_Tray1_text = new TextView("Left_Tray1_text");
           Left_Tray1_text.setText("Sample Text");
           Left_Tray1_text.setEncode(false);
           Left_Tray1_text.setWrapping(true);
           Left_Tray1.addComponent(Left_Tray1_text);
           RF_All.addComponent(2,1, Left_Tray1);
           Reg_Form.addComponent(RF_All);
    That code don't display Tray in page...

    Paul,
    I suggest you  not to add the your business logic in that auto generated file.
    Instead you can have seperate java file or any Bean.
    Since you are writing the logic for layout you can add the code in the jsp file
    itself.
    If you are using HTMLB Then keep the auto generated code in the jsp otherwise remove the code and keep the file as jsp meaning you use the html, javascript,
    jsp code in the .jsp file itself.
    you can add the java code in the jsp
    <% String strName = "SAP"; %>
    <sc ript>
    al ert("<%=strName%>");
    </sc ript>
    Ram

  • How to detect connection type (modem or LAN) in javascript or JS?

    Hi,
    I need to find out what type of connection (PPP or DSL or cable), user is using to browse the internet. Is there any way in javascript/jsp??
    Pleas let me know.
    Thanks,
    Kinjal

    I need to find out what type of connection (PPP or DSL
    or cable), user is using to browse the internet. Is
    there any way in javascript/jsp??
    Pleas let me know.
    Using java it would require using JNI and/or Runtime.exec().
    And in all likelyhood it would require a variety of different code to detect different types.

  • Applet/jsp communication

    I've written an applet that has three checkboxes and three textboxes. I've imbedded that applet inside a jsp. When the user checks one of the checkboxes, how do I check for that inside the jsp? Having determined which checkbox was chosen, I need to send data back to the appropriate textbox. How do I do that from the jsp?
    Thanks in advance for any help ... I'm just getting into this side of
    java/javascript/jsp coding.

    Well, you need to post the information to the jsp page in the querystring .. you can do that like this:
          * Example of passing vars to a script
         AppletContext appletContext = getAppletContext();
           try {
           URL url
                 = new URL(getCodeBase() + "script_setValues.php?x="
                           + image.getX() + "&y=" + image.getY() + "&width="
                           + image.getRecWidth() + "&height="
                          + image.getRecHeight() + "&createEventID="
                          + createEventID + "&mediaVersionID=" + mediaVersionID
                              + "&frameTemplateID=" + frameTemplateID
                              + "&percentageSize=" + percentageSize);
               appletContext.showDocument(url);
        } catch (MalformedURLException exception) {
             System.err.println("Error with URL");
           }Then you fetch it in the JSP page using the standard procedure for fetching information from the querystring .. haven't worked much with JSP so I do not know the exact code for this ..
    - bjorn

  • Servlet in Javascript src

    hi,
    I am having a servlet to generate the javascript menu. Now I have included in script tag like :
    <script type="text/javascript">
    <jsp:include file="/servletname"/>
    </script>
    But, Now I want to use it as a <script src="/servletname"> </script> is it possible. My idea is to avoid the servlet generate the dynamic java script menu code in the html file where it specifies. Than I want to specify as a source file like .js fil script src. Please give a reply asap.
    thank in advance,
    Murali.K

    Thank you for reply, I have done that, but the dynamic code from servlet is getting generated into the html file. But I don't want to see that code in html file. So I would like mention the servlet as a source for <script src="servletname" > like we mention the js file in <script src="myfile.js"></script>
    Thank You,
    Murali.K

  • Javascript includes

    Is there a way to "tunnel" included Javascript files through the portal server?
    For instance, if a portlet produces a Javascript include like so:
    <script src="http://foo.com/bar.js">
    the script needs to appear to come from the portal server or DHTML operations in it will not work due to the Javascript security model, which prohibits running scripts from different domains.
    FWIW, I haven't installed the portal yet; I am using portalstudio.oracle.com.
    Thanks in advance,
    Keith

    Thanks Sergey, but still doesn�t work. I tried to change to ajax4jsf 1.0.2.
    My problem occurs when I include a file with .js extension in my jsf page. If I change the extension of the include to .jsp it works.
    eg.:
    <script language="javascript">
    <jsp:include page="../recursos/scripts/select.js" flush="true"/>
    </script>
    i changed to
    <script language="javascript">
    <jsp:include page="../recursos/scripts/select.jsp" flush="true"/>
    </script>
    and inside select.jsp I involve the content of file with <script language="javascript"> </script>
    I�m using Tomcat 5.5 and tomahawk 1.1.3.
    Message was edited by:
    Chinvelski

  • Look up resources using a dynamic name

    I am using the <f:loadBundle ... /> tag to load localized resources in my JSP page. Now, I want to be able to look up resources from that bundle using a dynamic key. Like:
    <h:outputText value="#{resources.error-<%=code%>" />
    Or something like that, where code can be a request parameter to the JSP page. Seems like its something that would be common to want to do.
    Does anybody have any idea how to do that?
    Thanks for any help.

    That didn't work either.
    I think I'll just do it the old fashion way:Just send me your application (JSF version) and I will try make it work.
    On Monday you will get working version if I will capable fix your problem.
    My email: [email protected]
    I'm new to this JSF stuff I'm used to be delphi programmer and start to develop web application (using JSF) just couple month ago. That why sometimes I can't provide good answer. :)
    By the way, from your experience with JSF, is it
    mature enough to use in a production website? The
    only thing I'm using it for now is the localized
    resource bundle but that doesn't even do what I want.
    Not sure if JSF buys me anything versus just doing
    HTML/JavaScript/JSP.I created only one jsf application that include about 10 pages and using connections to MySQL.
    This application not in production yet because it's not finish, but it's work OK at least for one user :).
    I'm sure for complicate web site with different kind of data from different sources JSF is good way to go because it's easy connect presentation tier to business and data tiers. Don't forget also about possibility to create any kind of web components and rendering kits including rendering kit for virtual reality.
    We have web site with information about healthcare providers, services, schedules, accepted insurances.
    That the regular site with HTML/JavaScript/JSP and it's take to much time keep this site to today.
    Almost all information for site we can get from our database, but site using information from xml files.
    Of course we can create complicate jsp based web site with connection to database but it's mean you need bunch very good web developers.
    In near future I'm planning make all our web sites JSF based.

Maybe you are looking for

  • TS3212 I can't get the itunes download to run on my computer.

    I have Windows 8 and it shows itunessetup.exe in my downloads, but when I click to run, it won't run and finish the installation. I don't get any error messages, it just won't install. Does anyone have any suggestions?

  • Request for ideas: Postprocessing JSP output in Weblogic

    I would like to postprocess and transform an HTML DOM tree after it has been generated by a JSP. Said another way, I want to capture the output from a JSP, parse it, and potentially return something completely different to the client. I believe servl

  • How to display all the columns in the printpreview

    hi experts, I have developed an alv report using grid display. there are nearly 10 fields in the output with varrious of length. They get displayed correctly in grid format. But, when on the output screen, I click on List menu and goto "Print Preview

  • Move Excel Formatting on Operations performance issue

    Hi, Firstly we have a 64bit Windows system running EPM version V11.1.2.1, patched to .102, and Excel 2010 32 bit. Having applied patchset 13709867 on the .103 SV version the old problem we had where formatting was not maintained when a fixed format r

  • AdobeColorCommonSetRGB/Error 1603 installation solution

    I wanted to share this fix I found at another Adobe forum. I was getting this error, when trying to install CS4. I run Windows XP. AdobeColorCommonSetRGB Error: Error 1603. Fatal error during installation. What was happening here is that CS4 is tryin