I am not been able to receive URL parameters passed from my ajax code in my jsp.

Here is the code

function showDetails()
	  document.detailsForm.sltdUser.value = selectedUserID;
	  alert('selectedUserID' + selectedUserID);

	  var httpRequest;
	  var url  = 'showDetails.jsp?sltdUser = ' + selectedUserID;

      if (window.XMLHttpRequest) { // Mozilla, Safari, ...
          httpRequest = new XMLHttpRequest();
      else if (window.ActiveXObject) { // IE
          try {
              httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
          catch (e) {
              try {
                  httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
              catch (e) {}

      if (!httpRequest) {
          alert('Giving up :( Cannot create an XMLHTTP instance');
          return false;
      httpRequest.open('GET',url, true);
      httpRequest.onreadystatechange = function() { processResponse(httpRequest); };

  function processResponse(httpRequest) {

      if (httpRequest.readyState == 4) {
          if (httpRequest.status == 200) {
          } else {
              alert('There was a problem with the request.');



     String userId = request.getParameter("sltdUser");
   <script type="text/javascript">
     alert('userId' + userId);

The problem is in the alert I see that userId is not taking the value passed.

Kindly help.



One cant use client side code to get the server side code, if u try printing out the userId it should be there. what u can do is assign the userId to a hidden field then alert the value of the hidden field.

I have already solved this and u CAN send client side code to server side. The parameter needs to be appended to the URL twice.

so why isnt it marked as solved then?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.