Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Javascript Variable in JSP

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Javascript Variable in JSP

    Hai,

    Can anyone pls tell me how to access Javascript variable in JSP.Here is my code:

    <input type="checkbox" id="check1" value="<%=resultset1.getString(2) %>" onchange="call(this.value)"><%=resultset1.getStrin g(2) %>

    function call(elementid)
    {
    var arr = new Array();
    arr.push(elementid);
    for(var i=0;i<arr.length;i++)
    {
    document.getElementById("hidden3").value = arr;
    }
    }


    I need to use the Hidden valuie in JSP.Can anyone pls tell me how to get the value?Thanks in Advance


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,301
    Thanks
    181
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: Javascript Variable in JSP

    Can anyone pls tell me how to access Javascript variable in JSP
    Unless I misunderstand what you are actually trying to do, taking the above literally you cannot - JSP is server-side, javascript is client side. If you need to send data from javascript to the server, use AJAX or pass the data via GET/POST http requests.

  3. #3
    Junior Member
    Join Date
    May 2012
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Javascript Variable in JSP

    Hai copeg,

    Thanks for u r rply.Can u pls give me any sample code to send data from javascript to the server, using AJAX or by passing the data via GET/POST http requests.As i am new to Java,Pls give me any sample code or clear steps to get the data.

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,301
    Thanks
    181
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: Javascript Variable in JSP

    Quote Originally Posted by manjula View Post
    Hai copeg,

    Thanks for u r rply.Can u pls give me any sample code to send data from javascript to the server, using AJAX or by passing the data via GET/POST http requests.As i am new to Java,Pls give me any sample code or clear steps to get the data.
    I recommend you google how to use AJAX. There are ample number of examples online.

Similar Threads

  1. For-loop: initialisation of variable, can't set variable to value zero?
    By Bitbot in forum Loops & Control Statements
    Replies: 4
    Last Post: July 15th, 2012, 02:32 PM
  2. jsp javascript
    By mr.miku in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: November 19th, 2011, 12:38 PM
  3. Replies: 5
    Last Post: November 16th, 2011, 10:22 AM
  4. javascript problem
    By kundan_101 in forum Member Introductions
    Replies: 2
    Last Post: December 30th, 2010, 08:02 AM
  5. How can i put session in Javascript?
    By rajani in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: July 8th, 2009, 12:46 PM