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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:58:36+00:00 2026-05-27T21:58:36+00:00

I am trying to get form parameters from a GET request. The html code

  • 0

I am trying to get form parameters from a GET request. The html code is below.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>DesignMatch. Matching the best clients and best designers.</title>
        <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
        <script type="text/javascript" src="jquery.backstretch.js"></script>
        <script type="text/javascript" src="design_match.js"></script>
        <link rel="stylesheet" type="text/css" media="all" href="design_match.css" />
    </head>
    <body>
        <div id="matte_bg"></div>
        <div id="entire_wrapper">
            <div class="divModule" id="section_head_1">
                <p class="primaryPageText">
                    Clients
                </p>
                <div class="url-bar">
                    <form name="clientUrls" action="SaveDatabase2" target="_blank" method="get">
                        <input type="text" class="url-box" id="url-box1" name="name1" size="20" value="Paste a link to a website that has the design qualities you want.">
                        <a id="add-url" href="#">Add</a>
                        <a id="del-url" href="#">Remove</a>
                    </form>
                </div>
            </div>
            <div class="divModule" id="section_head_2">
                <p class="primaryPageText">
                    Designers
                </p>
                <div class="portfolio-bar">
                    <form name="designerUrls" action="SaveDatabase2" target="_blank" method="get">
                        <input type="text" class="portfolio-box" id="portfolio-box1" name="name1" size="20" value="Paste a link to a website you designed.">
                        <a id="add-portfolio" href="#">Add</a>
                        <a id="del-portfolio" href="#">Remove</a>
                    </form>
                </div>
            </div>
            <div class="divModule">
                <div class="filterSentence">
                    <ul class="primaryPageText">
                        <li>
                            &nbsp; To me, &nbsp;
                        </li>
                        <li class="budgetTypeFilter">
                            <a href="#" id="budgetToggle">[what price]</a>
                            <div id='budgetFilter' style="display:none" class="budgetTypeMenu">
                                <a href="/500-under">$500 and under</a>
                                <a href="/500-to-1000">$500-$1,000</a>
                                <a href="/1000-to-2500">$1,000-$2,500</a>
                                <a href="/2500-to-5000">$2,500-$5,000</a>
                                <a href="/5000-to-7500">$5,000-$7,500</a>
                                <a href="/7500-to-10000">$7,500-$10,000</a>
                                <a href="/10000-above">Over $10,000</a>
                            </div>
                        </li>
                        <li>
                            &nbsp; seems fair to pay for &nbsp;
                        </li>
                        <li class="budgetTypeFilter">
                            <a href="#" id="typeToggle">[what type of]</a>
                            <div id='typeFilter' style="display:none" class="budgetTypeMenu">
                                <a href="/basic">a basic (e.g., front-end only)</a>
                                <a href="/dynamic">a dynamic (e.g., a little back-end)</a>
                                <a href="/sophisticated">a sophisticated (e.g., lots of back-end)</a>
                            </div>
                        </li>
                        <li>
                            &nbsp; website. &nbsp;
                        </li>
                    </ul>
                </div>
            </div>
            <div class="divModule contact-bar" id="contact">
                <form name="nameForm" action="SaveDatabase2" target="_blank" method="get">
                    <input type="text" id="name_form" name="name_form" size="20" value="Tell us your name.">
                </form>
                <form name="contactForm" action="SaveDatabase2" target="_blank" method="get">
                    <input type="text" id="contact_form" name="contact_form" size="20" value="Enter your e-mail (no spam, ever).">
                </form>
            </div>
            <div id="submit">
                <form accept-charset="UTF-8" action="SaveDatabase2" method="get">
                    <input class="btn primary large" id="submit-button" name="submit" type="submit" value="✔" />
                </form>
            </div>
        </div>
    </body>
</html>

Here is the Servlet code. The parameter values I get in doPost are null. I tried changing all the get requests to post in the html and it didn’t help. The doGet function is just rerouted to doPost. The two main parameters I am interested in right now are the “contact_form” and “name_form” parameters at the end of the html. Thanks again!

package web;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mysql.jdbc.StringUtils;
import java.sql.*;
import java.io.*;
import java.util.*;

/**
 * Servlet implementation class SaveDatabase2
 */
public class SaveDatabase2 extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public SaveDatabase2() {
        super();
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doPost(request, response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<h1> Thank You </h1>");

        //Get Info for Database     
        int designer=0;
        String clientType="";
        String name= "";
        String email="";
        //Get parameters to put into database
        Enumeration parameterNames = request.getParameterNames();
        if ((request.getParameter("designerUrls")!=null) && !request.getParameter("designerUrls").matches(".*\\w.*") ){
            designer=1;
        }
        if (designer==1){
            clientType="designer";
        }else clientType="client";

        name= request.getParameter("name_form");
        email=request.getParameter("contact_form");

}
  • 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-05-27T21:58:37+00:00Added an answer on May 27, 2026 at 9:58 pm

    First of all, I think you should leave doPost and doGet as 2 different methods. doPost will automatically be triggered if you set the attribute method of your form to post.

    Besides, your form should be like this:

    <form name="myForm" accept-charset="UTF-8" action="SaveDatabase2" target="_blank" method="post">
       <input type="text" id="name_form" name="name_form" size="20" value="Tell us your name.">
       <input type="text" id="contact_form" name="contact_form" size="20" value="Enter your e-mail (no spam, ever).">
       <input class="btn primary large" id="submit-button" name="submit" type="submit" value="✔" />
    </form>
    

    In your question, the submit button is in its own form which does not contain the 2 input text fields: name_form and contact_form. That’s why you got the null values.

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

Sidebar

Related Questions

I am trying to get some form data from POST method. Here's the code
I'm trying to get all the input elements from a certain form from jQuery
I'm trying to get a PUT request from Python into a servlet in Tomcat.
I'm trying to send a GET request to a App Engine server from a
I'm trying to pass some parameters (count) from a form to a model. The
Im trying to get a form working in Internet Explorer. I see that when
I have a contentPane with a remote form, I'm trying to get the form
I am trying to get post a form to a hidden, dynamically inserted iframe,
I'm trying to get my C# form to be parented correctly in a third
I am trying to get center of parent form, not center of screen behavior.

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.