Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
Unable to get the value using requestParameter

I'm trying to retrieve the value in JSP which has been submitted via XHR request in HTML

Below is the HTML code for reference

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.js">
</script>
<script>
function click() {
    var xhr = null;
    if (navigator.appName == 'Microsoft Internet Explorer') {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    } else if (navigator.appName == 'Netscape') {
        xhr = new XMLHttpRequest();
    }
    xhr.open('POST', "verify.jsp", true);
    var params = 'empIds=' + '123';
    xhr.onreadystatechange = function() {
        if (xhr.readyState == XMLHttpRequest.DONE) {
            alert(xhr.responseText);

        }
    };
    xhr.send(params);
}
</script>
</head>
<body>
<p><button onclick="click()" type="button">Click</button></p>

Below is the JSP Page which retrieves the value submitted

<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<HTML>
<HEAD>   
</HEAD>
<BODY>
<BR>
<%
  long timeInMilliSeconds = System.currentTimeMillis();
  String empId = request.getParameter("empIds");
  out.print("emp Id: "+empId);
%>
</BODY>
</HTML>

Actual Result: empId: 
Expected Result:empId: 123

JSP should retrieve the value and send the same value back to HTML

Reason: String empId = request.getParameter("empIds"); is returning null.

Thanks

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!