-3

Here is my JavaScript file where my goal is to send value of variable va to jsp file and output it.
The problem is that I can't find the bug.

JavaScript file
$(function(){
  $("td").click(function() {
    var date     = $(this).html();
    var message  = prompt(year+"year "+month+"month "+ date+"day","null!");
    this.append(message);   
    var variable = "mememem";
    var sendData = new XMLHttpRequest();
    sendData.onreadystatechange = function() {
      if (this.readyState == 4 && this.status == 200) {
        alert("connected to server");
      }
    };

    sendData.open('GET','dataFile.jsp?na='+variable,true);
    sendData.send(null);
    window.location = "dataFile.jsp"; 
  })
});
JSP file
<%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
    <title>Insert title here</title>
  </head>
  <body>
<%
  String name = request.getParameter("na"); 
  out.print(name);
%>
</body>
</html>
2
  • 2
    What "bug"? What goes wrong? What are the errors? Commented Feb 5, 2018 at 0:22
  • @Pointy request.getParameter("na"); sends out null Commented Feb 5, 2018 at 0:33

1 Answer 1

0

I think the problem is you're sending variable instead of va.

This line:

sendData.open('GET','dataFile.jsp?na='+variable,true);

Hope that is the root cause of your problem.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.