Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8203123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:26:16+00:00 2026-06-07T07:26:16+00:00

I want to generate a SQL query when I press the submit button and

  • 0

I want to generate a SQL query when I press the submit button and show the number of rows it returns without refreshing. I’ve manage to do this below, but it refreshes and clears everything and the value is always 0. I’m using Tomcat and NetBeans.

  • I’m using the submit function because after I solve this I will return false if something happens.

  • The msg span is where the rows returned are going to be displayed.

  • Funciones.setSql generates the SQL using the value on the option selected and stores in a static String. Then the Funciones.count() just makes the query and stores the number of rows in a variable called numF.

  • Funciones.lista() generates all the data in the database using one specific field and setting a value (id).

JSP:

<div data-role="page" id="realizadas">
    <%@include file="header.jsp"%>
    <div data-role="content">
        <form name="tareasr" id="tareasr" data-mini="true" method="post">
            <fieldset data-mini="true" data-role="controlgroup" data-type="horizontal"> 
                <select data-inline="true" name="vina" id="vina">
                    <option value="0">VIÑAS</option>
                    <%=Funciones.lista("VINA","option")%>
                </select>
            </fieldset>
            <input data-icon="search" type="submit"  value="Buscar" />
        </form>
        <b><span id="msg"></span></b>

        <script>

            $("#tareasr").submit(function() {
            <jsp:useBean id="formHandler" class="ges.FormBean">
                <jsp:setProperty name="formHandler" property="*"/>
            </jsp:useBean>
                var men="Num: ";
                <%Funciones.setSql(formHandler.getVina()); 
                Funciones.count();%>
                men+=<%=Funciones.numF%>;
                alert(men);
              $("#msg").text(men).show().fadeOut(3000);
            });
        </script>
    </div>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:26:18+00:00Added an answer on June 7, 2026 at 7:26 am

    You’re mixing Java code and JavaScript code as if they were the same thing. Java code inside a JSP should be avoided, and if it’s there, it must be inside scriptlet tags (<% ... %>). Thsi Java code is executed at server-side, when the JSP is executed and the HTML and JavaScript code is generated.

    Then, in the browser, JavaScript code can be executed. This JavaScript code can’t invoke methods of Java objects which were used to generate HTML at server-side. Java doesn’t exist in the browser. If you need to invoke server-side Java code from the browser, you must send a new HTTP request to the server (by clicking a link, submitting a form, or sending an AJAX request).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to generate this SQL statement in LINQ: select * from Foo where
Trying to generate XML file from returend SQL query results. The SQL query returns
I want to generate SQL like this: SELECT coalesce(max(a.a_index) + 1, 0) as a_index
I want to generate a dynamic SQL where clause from a Scala collection, such
I have a multi-table SQL query. My need is: The query should I generate
Using SQL Server 2005 I want to generate the table values between the two
Using VB.NET and SQL Server 2005 I want to generate a date according to
I have an sql query that returns a lot of results for which I
I generate an Excel using an SQL query per each day: SELECT COUNT(res_id) as
I have a very complex Linq to SQL query that returns a result set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.