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 8830699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:09:16+00:00 2026-06-14T08:09:16+00:00

So I am trying to use a simple form to get input from a

  • 0

So I am trying to use a simple form to get input from a user, retrieve the necesary info from the database, and post it. However, on the HTML page, the submit button just clears the form. Below is the html file and the java file that is referenced in the action. I know the file that interacts with the database is missing but I think my issue lies in one of these two. I can post it later if needed. My question is, why is the submit button clearing the form instead of bringing you to the site in “action”?

<form>
        <FORM METHOD=POST ACTION = "http://uml.cs.uga.edu:8080/michael_crosby_courses/Schedule">
        Class 1: <input type=text name="Class1"><br>
        Class 2: <input type=text name="Class2"><br>
        Class 3: <input type=text name="Class3"><br>
        Class 4: <input type=text name="Class4"><br>
        <input type=submit>
</form>





import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Schedule extends HttpServlet {

public void doPost(HttpServletRequest  req, HttpServletResponse res) throws ServletException, IOException {

    PrintWriter toClient = res.getWriter();
    String field;
    String val;
    Vector classes = null;
    Vector totalHours = null;
    String query = null, query2 = null;
    String class1 = null, class2 = null, class3 = null, class4 = null;
    int i, sum=0;

    res.setContentType("text/html");

    toClient.println("<html>");
    toClient.println("<title>MyEcho</title>");
    toClient.println("<body>");

    Enumeration values = req.getParameterNames();

    if( values.hasMoreElements() ) {

        class1 = req.getParameter("Class 1");
        class2 = req.getParameter("Class 2");
        class3 = req.getParameter("Class 3");
        class4 = req.getParameter("Class 4");
        toClient.println("<P><P><B>Your Schedule:</B></P></P>");
        query = "select * from csci_section where number = " + class1 + " or number = " + class2 + " or number = " + class3 + " or number = " + class4 + ";";

    }

    query2 = "select credit from csci_section where number = " + class1 + " or number = " + class2 + " or number = " + class3 + " or number = " + class4 + ";";

    if( query == null )

        toClient.println("<P><P><B>No query given;  resubmit </B>");

    else if(1==1) {             //if the request did not return anything, i.e. the number given is not a class

    } else{

        toClient.println("<P><B>Running search for classes: </B>" + class1 + ", " + class2 + ", " + class3 + ", " + class4 + ", "  + "<P><P>" );

        classes = AccessMySQL.Execute( query );
        totalHours = AccessMySQL.Execute(query2);
        toClient.println("<P><P><B>Received classes: </B></P></P>");

        for( i = 0; i < classes.size(); i++ ){ //prints out info

            toClient.println( "<p><tt>" + (String)classes.elementAt( i ) + "</tt></p>" );

        }

        for(i=0; i < totalHours.size(); i++){
            sum += Integer.parseInt((totalHours.elementAt(i)).toString());
        }
        toClient.println("<p><tt>The total number of class hours is: " + sum + "</tt></p>" );
    }

    toClient.println( "</body>" );
    toClient.println("</html>");

    toClient.close();


} //closes doPost

}

  • 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-14T08:09:18+00:00Added an answer on June 14, 2026 at 8:09 am

    Because you have two <form> tags. The first one (with no action) is the one that the browser users. Remove it and it should start working as expected.

    <form>  <-- Remove this one
        <FORM METHOD=POST ACTION = "http://uml.cs.uga.edu:8080/michael_crosby_courses/Schedule">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use a simple HTTP get to load a string from a
I'm trying to use a simple PHP mail() function to create user feedback from
I am trying to make a simple html page that takes info from two
I'm trying to do a simple user validation, however, when I try to use
I'm trying to use the i18n feature of simple form, which works great in
I am trying to create an html form that uses AJAX to load database
I'm trying to write a little form which accepts some user input, and on
I'm trying to use Simple Savant within my application, to use SimpleDB I currently
I've used ITK with c++ some time ago and I'm trying to use simple
I am trying to use a simple MySQL insert query with the parameters in

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.