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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:01:45+00:00 2026-05-16T09:01:45+00:00

I have to do an HTML page with 2 text boxes, one for name

  • 0

I have to do an HTML page with 2 text boxes, one for name and the other one for ammount, then theres a widget that let me choose which type of account im creating, savings or checking, then a send button, this information is going to be sent to the servlet. The servlet have to create an object depending on the type of account, then save it on a Vector, then the servlet need to respond an HTML textarea with the information thats on the Vector, and the same widgets that were in the first page so you can insert another account, when you insert another one you have to send the information to the same servlet, and then do the same work. But in the HTML text area must appear the first account and the one that I just created, and so on and on.

The thing is that I can do all of this but what I can’t do is the showing all the information of the vector for some reason I just get the account that I just created in the text area.

Here’s the servlet code. Note, the toString() returns all of the info thats stored on the Vector, and addAccount() adds the account to the Vector.

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

public class ServletPrincipal extends HttpServlet {
    public void doPost(HttpServletRequest request,
                       HttpServletResponse response)
    throws ServletException, IOException {

        response.setContentType("text/html");

        PrintWriter out = response.getWriter();

        String nombre = request.getParameter("nom");
        String monto = request.getParameter("mon");
        String tipo = request.getParameter("fgcghch");


        double montoi = Double.parseDouble(monto);
String a="ah";
String b="che";

AccountsLedger objeto = new AccountsLedger();

if(a.equals(tipo)){

    SavingsAccount cnt1= new SavingsAccount(nombre, montoi, 2);

    objeto.addAccount(cnt1);

    objeto.toString();
    out.println("<textarea rows='20' cols='20'>"+objeto.toString()+"</textarea>");
    out.print("<form action='ServletPrincipal' method='post'><input type='text' name='nom'><input type='text' name='mon'>");
    out.println("<select name='fgcghch'><option value='ah'>Ahorro</option><option value='che'>Cheque</option></select>");
    out.println("<input type='submit' name='boton'></form>");
    }
if(b.equals(tipo)){


CheckingAccount cnt= new CheckingAccount(nombre, montoi);



objeto.addAccount(cnt);
String y = objeto.toString();
out.println("<textarea rows='2' cols='20'>"+y+"</textarea>");
    out.print("<form action='ServletPrincipal' method='post'><input type='text' name='nom'><input type='text' name='mon'>");
    out.println("<select name='fgcghch'><option value='ah'>Ahorro</option><option value='che'>Cheque</option></select>");
    out.println("<input type='submit' name='boton'></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-16T09:01:46+00:00Added an answer on May 16, 2026 at 9:01 am

    First, don’t use Vector, use ArrayList. It works the same but does not used synchronized keywords on the methods which is actually a good thing for performance. It is very rare indeed that two threads will access an array and if they did the synchronized keyword is pretty useless anyway for a collection class.

    Second, consider if you want to write a servlet here or whether a JSP would be better. A JSP is basically an inside out servlet so if there is more HTML than Java it makes sense.

    Thirdly, to iterate an ArrayList with modern Java is trivial, so if the intent is to create a string to insert into HTML, then it can be done like this:

    ArrayList<String> values = // ... built somewhere
    StringBuilder sb = new StringBuilder();
    for (String v : values) {
      sb.append(v);
    }
    out.println(sb.toString());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two text boxes t1 and t2 in an html page. I'd like
I have a multiple text boxes in a form in a HTML page. I
I have this html page which is very simple, it contains a text box
Lets say i have an external html page and I want to append text
I have used fieldset tag in HTML page, whereby i need some text to
If I for example have <p> some long text </p> on my HTML page,
I have an HTML table in my jsp page. This conains text fields and
I have a web page with a read-only text box which shows some HTML
On extracting some html from a web page, I have some elements containing text
How can I update the text fields with HTML? I have a page with

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.