How come my Java program is revealing all of its code on the screen rather than just displaying the information I provide when making an ajax call to it?

In my current project, I aim to utilize an ajax call for the client to post to a Java program, interact with the database, and display the results on my web page. Although my intention is to have Java print a simple greeting, the output currently displays all the code instead.

Below is the ajax call being used:

getText = function(duty){

$.ajax({

type: "POST",

url: 'querymanager.java',

data: (duty),

success: function(data){

console.log(data);

}

});

}

Here's the Java program it references:

class MyTestClass{

public static void main(String args[]){

try{

System.out.println('And here is the text to return to my website');

}

}

Answer â„–1

Attempting to directly call your Java function from a JavaScript script is not the correct approach.

The URL for querymanager.java is incorrect.

You must create an HTTP endpoint that will properly invoke this function and provide you with the results.

Unfortunately, the implementation of this process is outside of the current scope.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Concurrent methods within a Runnable

I have developed a Runnable class that consolidates messages for a period or until reaching a specified size before sending them over the network. This implementation allows external threads to modify certain internal parameters (such as packet size) while ...

Find the minimum and maximum sum of five integers with Min-Max Sum challenge

Given a set of five positive integers, calculate the minimum and maximum values that can be obtained by summing exactly four of the five integers. Print the resulting minimum and maximum values on a single line, separated by a space. Example: arr = [1, 3 ...

Is it possible to assign a property value to an object based on the type of another property?

In this illustrative example: enum Methods { X = 'X', Y = 'Y' } type MethodProperties = { [Methods.X]: { x: string } [Methods.Y]: { y: string } } type Approach = { [method in keyof Method ...

What is the best way to pass the "$user" variable in a loadable file using ajax?

Is there a way to send the variable user to the mLoad.php file before executing this script? Any suggestions would be greatly appreciated. Thank you! $(document).ready(function(){ $("#message_area").load('mLoad.php'); $("#userArea").submit(func ...

Difficulty in decoding intricate JSON response using JQuery (or simply JavaScript)

Consider the function below, which retrieves JSON data from a Solr instance: var url = "http://myserver:8080/solr/select?indent=on&version=2.2&q=(title:*Hollis* OR sub_title:*Hollis*+OR+creator:*Hollis*+OR+publisher:*Hollis*+OR+format:*Hollis*++OR ...

Submitting an AJAX form without refreshing the parent page in PHP

I'm encountering some issues with an AJAX form submission. $("#send").on("click", function() { $.ajax({ type: "POST", url: "ads_process.php", data: $("#ads").serialize(), success: function(){ if(data == ...

How can we prevent a marker's click event from firing again after a single click has

When a marker is clicked, I want to: Turn off the clickable functionality on the map Pause for 5 seconds Turn the clickable feature back on after executing an ajax request and using setInterval for a duration of 3 seconds. Below is my updated code snippe ...

Tips on creating visual mini dialogs with images

I’ve come across these dialogues in some apps, but I've been struggling to find out how to display / generate them. Am I overlooking something that's right in front of me? Your assistance is greatly appreciated! https://i.sstatic.net/AAoIW.png ...

The React data editor Dialog closes when the drop-down is clicked without triggering any onChange events

Utilizing the react-datasheet component, I have implemented a table to display a matrix/grid of data. To enhance user experience, I customized the dataEditor to launch a custom dialog where users can only choose from preselected values in a material-ui dro ...

Is it possible to use programming to invoke a function with the identical name from within another function in Javascript or Typescript?

Currently, I am working with Typescript but presenting this question in Javascript. Any assistance for either language would be greatly appreciated. I have two objects that share the same interface. My goal is to create a third object with the same interf ...

Having trouble creating the right XPath for the top movies on IMDB using Selenium

I'm having trouble clicking on the Top Rated Movies section within "Movies, TV & Showtimes" on IMDB. I'm unsure of how to write the correct xpath for it and can't seem to figure out how to click on it. Below is the snippet of code I am usin ...

I am trying to figure out how to properly utilize server-only functions within Next.js middleware

In my current project, I am utilizing Next.js 13 along with the App Router feature. While attempting to include a server-specific fetch function in middleware.js, an error message is encountered: Error: Unable to import this module from a Client Compone ...

Understanding the structure of an Express application

Below is an excerpt from express code that was generated automatically: //Loading configurations //if in test environment, load example file var env = process.env.NODE_ENV || 'development', config = require('./config/config')[env], ...

Aggregate X and Y values based on a key in a scatter plot using dc.js

Here is a glimpse of my dataset: var items = [ {name: "X", duration: 1, quantity: 2}, {name: "X", duration: 2, quantity: 1}, {name: "Y", duration: 1, quantity: 4}, {name: "X", duration: 3, quantity: 1 ...

Error: The database has encountered a duplication error in the followers index of the MERNSM.users collection, with a duplicate key value of undefined

Encountered a MongoServerError: E11000 duplicate key error collection: MERNSM.users index: followers_1 dup key: { followers: undefined }. This is puzzling as there is no unique constraint set in my schema. I am unsure of what could be causing this issue, e ...

Translating .NET webclient request into JavaScript Syntax

I have a piece of .NET code that I need help converting into Javascript/jQuery. I'm thinking it might involve using AJAX, but I'm not sure how to go about it. Can someone here assist me with this? public  string  SendSMS(string  recipient,  ...

Trouble with retrieving the Even-Numbered Columns from a Two-Dimensional Array

I need help extracting the values in the EVEN columns from a given 2D array. Here is the code I have written: public static void main(String[] args) { int [][] rearra = new int[5][3]; int[][] arra = { {01,02,03,04,05,06}, ...

Analyzing an External File containing JSON formatted columns

As a newcomer to this site, I welcome any feedback on my approach. My current project involves exploring the 6 degrees of Kevin Bacon by utilizing an external CSV file to create an unweighted graph. The goal is to allow users to determine the shortest path ...

Creating a webpage that loads directly to a specific section of content

After searching online, I couldn't find the solution I was looking for. My goal is to have the visible part of the page load halfway down the actual page. This way, when users visit the site, they can immediately scroll up to see more content. I hope ...

Error: The variable "context" has not been defined

I am currently facing an issue while trying to develop a sendNotification function using node.js and Firebase function. I am encountering a problem where I am not receiving any notifications from the sender, and upon checking the Firebase function logs, I ...