Send multiple forms simultaneously using a single button in JSP

I am facing an issue while trying to submit two forms using just one button. The value of the first form input appears to be null.

test.jsp

<body>
            <script>
                function submitAllForms(){

                    console.log($('input[name=valueDateFromFilter]').val());
                    console.log($('input[name=valueDateToFilter]').val());

                    document.formDateFromFilter.submit();
                    document.formDateToFilter.submit();
                };
            </script>

                <form method="post" action="./Servlet" name="formDateFromFilter">
                    <input class="span2" size="16" type="text" name="valueDateFromFilter">
                </form>

                <form method="post" action="./Servlet" name="formDateToFilter">
                    <input class="span2" size="16" type="text" name="valueDateToFilter">
                </form>

            <a class="btn" href="#" onclick="submitAllForms();"><i class="icon-message"></i></a>

        </body>

doPost method in Servlet.jsp

protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
  String a = request.getParameter("valueDateFromFilter");
  String b = request.getParameter("valueDateToFilter");
  System.out.println(a);
  System.out.println(b);
}

While checking the browser console, I can see values for both strings. However, when inspecting the server log console, the value of the first string (variable a) is showing as null.

Answer №1

Creating a more efficient solution might involve developing a JSP/servlet that can handle and process both data sets simultaneously, allowing for seamless communication between different servlets on the server side.

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

What is the best way to distribute javascript and html code across multiple elements on a webpage?

My webpage has a unique feature - two textboxes that trigger a bootstrap modal with a searchable treeview when clicked. The selected item from the treeview automatically populates the textbox. It's a flawless process! Recently, I decided to implement ...

Issue with FileStreamResult not triggering download prompt after AJAX call in MVC

I am encountering an issue with my code that is triggered by the "export" li tag. It converts a FusionChart to an SVG string and then sends it to my controller via an ajax call. The problem I'm facing is that even though the controller receives the r ...

Can you identify the issue in this Three.js skybox code?

My attempt to create a SkyBox with ThreeJS code was unsuccessful. Instead of rendering properly, it quickly flashed for a second and then turned black. The code I used is shown below: <html> <head> </head> <body> <script sr ...

Encountering issues accessing the key value 'templateUrl' in Angular6

I have an object in my component.ts file that I need to iterate through in the HTML template using a ui-comp-menu element. menuObject = [{ 'labels': 'Content1', 'templateUrl': 'assets/partials/sample.html ...

Steps to sending a parameter to an AngularJS $http success callback

In my AngularJS application, I have implemented the following code: $http.get('/plugin/' + key + '/js').success(function (data) { if (data.length > 0) { console.log(data); // Here, I also need to retrieve the val ...

ReportViewer Web Form sending page into a frozen state

Recently, I was tasked with investigating a seemingly simple issue on one of our web pages within a small dashboard web application. This particular app displays basic state information for the backend apps that I am heavily involved in working on. Here is ...

Deploying Javafx Maven projects using Intellij IDEA

I initiated a JavaFX Maven project in IntelliJ IDEA. The program runs smoothly within the IDE. I added the javafx-maven-plugin to deploy my project. However, when I executed the javafx-maven-plugin:jfx:build-jar command, an error log was generated: "C:&bs ...

Decoding and encoding characters in struts HTML

I have configured my Tomcat server.xml, web.xml, and jsp page encoding to be "UTF-8". However, when an html form posts special characters such as Ď. I use StringEscapeUtils.unescapeHtml4(str) in Java code to save this special character Ď in the database ...

Proceed with the second axios call only if the first one meets certain conditions

I am attempting to implement a feature where I can check the response object from the initial axios call, and if it is empty, proceed to the second call (otherwise, I will generate an error message). Essentially, the second axios call should only be trigg ...

Mobile devices are unable to properly implement the Jquery show/hide feature

Currently, I am working on a small Russian project and facing some challenges with the mobile version of my website: php8098.github.io/breakfast. The issue lies within the first slider where the play button should trigger a modal window to open. I urgentl ...

Tips for handling notifications that have been read and unread in a React application

In my current project using React JS, I am tasked with creating a notifications component that will display account-related activities. The notifications need to be sorted into read and unread categories. My main question is how should I manage the read a ...

Encountering a "dependency resolution error" while deploying a React application with Parcel on Heroku

I've developed a compact application and I'm in the process of deploying it to Heroku. However, I keep encountering an error stating: '@emotion/is-prop-valid' dependency cannot be resolved. It's worth mentioning that this project d ...

Ways to show dropdown menu link exclusively on mobile browsers and not on desktop browsers

<li class="megamenu-content"> <div class="megamenu-content-wrapper clearfix"> <ul class="col-lg-3 col-sm-3 col-md-3 "> <li class="cat-header">DISPLAY MEMBERS</li> ...

I'm curious if it's possible to modularize a Page Element in Next.js that receives staticProps through a parsedUrlQuery

The scenario involves opening http://localhost:3000/users/101 Desired layout for the page and integration of the second code snippet in [id].tsx import CTASection from '../../components/samples/CTASection'; import { User } from "../../inte ...

Is there a way to optimize Typescript compiler to avoid checking full classes and improve performance?

After experiencing slow Typescript compilation times, I decided to utilize generateTrace from https://github.com/microsoft/TypeScript/pull/40063 The trace revealed that a significant amount of time was spent comparing intricate classes with their subclass ...

Connection error: API is down

The current issue I am facing with the application I'm developing is that it is not responding with the API address for weather data. Despite getting a response from Ajax, the specific weather API I am trying to call remains unresponsive. I have exha ...

No response from submitting HTML form

I'm a beginner and need some help with my form. I have two submit buttons and two actions but nothing is happening when I click on them. Here's my code: <form id="form1" name="form1" method="post"> Enter Amount*: <input type="text" name ...

Ways to manage your javascript variables

Here is the code snippet I am working with: var json = jQuery.parseJSON(data); console.log(json) When I run this code, the output looks like this: Object {sql: "SELECT venta.cliente_tipodoc,count(*) AS cantidad FROM venta venta", results: Array[1], ...

Is it possible to display one division on top of another with a transparent opacity effect in HTML?

I'm struggling with designing web pages and currently working on a page on codepen.io using code from this link. <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1 ...

Issue occurred while trying to set the value from an API call response in the componentDidMount lifecycle method

There is a boolean variable disableButton: boolean; that needs to be set based on the response received from this API call: async getDocStatus(policy: string): Promise<boolean> { return await ApiService.getData(this.apiUrl + policy + this.myEndpo ...