0

Im looking for a way to get the x,y coords of where I clicked in my WebApp using Java EE only. But this seems to be impossible(correct me if Im wrong).

So I`ve tried to use JS to pass the variables. I know I can use either forms or ajax, but those seem to be limited to one direction, so that I can only send values from Java--->JSP and not the other way around. It seems I can only send strings from JSP--->Java.

Is there a way to - instead of the alert - send thos values directly to a servlet, in the following fiddle?

$(document).ready(function(e) 
 {
    $('#A').click(function(e) {
        alert(e.pageX+ ' , ' + e.pageY);
    });    
});
#A 
{ 
  width:100px;
  height:100px;
  cursor:pointer;
  background:#2f2f2f;
  position:absolute;
  top:50px;
  color:#fff;
  font:bold 15px Arial; 
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<head>
 <title> Mouse Positions !! </title>
</head>
    
<body>
    <div id="A" style="left:100px;"> Default    
      <br /> mouse <br/> position 
    </div>
 </body>

</html>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Fuby
  • 66
  • 10

1 Answers1

0

I solved it. I used a form to send an request. It's possible to modify the forms value via JS, also its possible to submit via JS. Just find the form by id and change the value.

Fuby
  • 66
  • 10