dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Sending request parameters in JSP using Ajax

  1. #1
    Join Date
    May 2008
    Posts
    3

    Sending request parameters in JSP using Ajax

    Hi

    Below is a code snippet in JSP

    Code:
    <form name="test">
    <input name="fname" value="changeMe" onchange="AjaxCalling()"/>
    </form>
    Ajaxcalling() is a javascript function using ajax.
    where i am sending a request to another JSP page, which will read the request parameter "changeMe".

    AjaxCalling()
    // sending request
    Code:
    ajaxObject.open("get", "second.jsp", true);
    ajaxObject.send(null);
    but in Second.jsp when i am trying to read request parameter
    Code:
    request.getParameter("fname");
    It is giving NULL.

    This works fine if i am not using ajax as below :
    Code:
    <form name="test" action="second.jsp" method="get">
    <input name="fname" value="changeMe"/>
    <input type="submit" value="submit"/>
    </form>
    Please help me out.

    Thanks

  2. #2
    Join Date
    May 2008
    Posts
    4
    I suggest sending the value through a url var such as.
    Code:
    var date = new Date();
    url="second.jsp";
    var fname=document.getElementById("fname").value;
    getUrl="?fname="+fname+"&time="+date.getTime();
    createRequest();
    request.open('GET', url + getUrl, true);
    request.send(null);
    I append the date to the end of all request so that all request urls are different. This stops ie from caching all request then just using the cached information instead of remaking the request.

Similar Threads

  1. Replies: 1
    Last Post: 05-02-2007, 02:01 PM
  2. Ajax - Cant pass value from jsp page to js
    By vitalstrike82 in forum AJAX
    Replies: 1
    Last Post: 10-12-2006, 03:09 AM
  3. Handling XMLHttp request in JSP
    By jijesh in forum Java
    Replies: 0
    Last Post: 07-19-2005, 08:55 AM
  4. Xindice query
    By nonolap in forum XML
    Replies: 0
    Last Post: 05-26-2005, 04:10 AM
  5. Sending a servlet responce through the JSP parser
    By Marc Boorshtein in forum Java
    Replies: 0
    Last Post: 04-10-2000, 07:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center