checkboxes and radio buttons using JSP and servlets
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: checkboxes and radio buttons using JSP and servlets

  1. #1
    Join Date
    May 2001
    Location
    Puerto Rico
    Posts
    26

    checkboxes and radio buttons using JSP and servlets

    HI!

    I am making a calculator using JSP that sends a request to a servlet that calculate some values, this calculator contains a series of values that users has to enter. These values are entered using checkboxes, text fields, selects, and radio buttons. My problem is that if a checkbox or radio button is not selected, the servlet do not make a response.
    Some of the fields do not require that the person check a checkbox, he/she can left some in blank.

    Could someone give me some code to make the servlet respond even when the checkboxes are not checked??
    Thanks

    JNP

  2. #2
    Join Date
    Jun 1999
    Location
    SW Missouri
    Posts
    3,439

    Re: checkboxes and radio buttons using JSP and servlets

    To change the way your current servlet handles the HTTP requests it gets will require that it be modified. Code from another servlet might not work with the one you are using.
    You will need to modify your servlet's code so that it will always return a response. In other words it should always write some HTML to be sent back to the client's browser. Look at the logic of the servlet and see where it can exit without writing a response and change it so that it does.
    How does the servlet fit in with the rest of your code?
    Does the JSP send HTML to the client's browser in response to an HTTP request, then the client fills in a Form and submits it back to the server where the servlet does its thing and returns some HTML to the client's browser again?

    Norm
    Norm

  3. #3
    Join Date
    May 2001
    Location
    Puerto Rico
    Posts
    26

    Re: checkboxes and radio buttons using JSP and servlets

    You asked: Does the JSP send HTML to the client's browser in response to an HTTP request, then the client fills in a Form and submits it back to the server where the servlet does its thing and returns some HTML to the client's browser again?
    ---->>Yes it does.
    Frankly I am new with servlets and I didnt understand very well the solution you gave.







    JNP

  4. #4
    Join Date
    Jun 1999
    Location
    SW Missouri
    Posts
    3,439

    Re: checkboxes and radio buttons using JSP and servlets

    To write servlets and JSP and HTML you need to understand where each are executed, created or displayed. HTML is created by servlets and JSP executing on a server computer. They are called when a browser displaying some HTML on a client's computer submits a HTTP request to the server computer that addresses the servlet or JSP.
    The HTML Form being displayed on the browser has several parts that you need to know about. The ACTION attribute for example. Also you need to know how the fields from the HTML Form are encoded when they are passed to the server upon submission from the client. They are in keyword=value pairs following a ? and separated by &. Most of this is hidden from you by the servlet engine, but you need to know it.
    The servlet needs to retrieve these values to get the data that the user has entered in the Form. There are Servlet methods for doing it. Read the doc to see which you need to use.
    For some reason your servlet does not send a response to the client when the user does not set a checkbox.

    The SOLUTION: You have to look at the servlet's code to see when it does send a response and when it does not. Without seeing the code, no one could tell you how to make the changes.




    Norm
    Norm

  5. #5
    Join Date
    May 2001
    Location
    Puerto Rico
    Posts
    26

    Re: checkboxes and radio buttons using JSP and servlets

    I have solved my problem... it was a simple error reading the checkboxes value and some if condition I was using was not right.

    Thanks anyway, you cleared me some dudes I had about servlets.

    JNP

  6. #6
    Join Date
    Apr 2013
    Posts
    1

    Thumbs up easy to work with radio buttons using JSP and servlets

    i found out easy way to ma probs and work out with radio buttons using jsp servlet
    http://webideaworld.blogspot.com/201...h-servlet.html
    may be it can help u....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center