Add to database using jsp, beans and serlvets??

I am trying to pass a form from my index.jsp page to a servlet, where the data will be added to a database. I am using mvc so none of the processing is done in the servlet, but i cannot get the form to pass to the servlet. i am using netbeans 4.1 with a sql database.I have been trying to solve this for some time so any feedback would be much appreciated.

index.jsp
declaring the bean
package com.football
<jsp:useBean id="team" class="com.football.NewBean" scope="session" />
<jsp:setProperty name = "team" property = "name" value = "name" />
<% session.setAttribute ("team", team); %>

then the form
<FORM action = "team" method="POST">
      
      <input type="hidden" name="ACTION" value="LIST_ADD" />
      <tr>
        <td colspan="2"><b>Add new Team</b></td>
        <td><input name="name" type="text" size="20" value= ="team.name"  /></td>
        <td><input name="ADD" type="submit" value="Add" /></td>
        <td>&nbsp;</td>
      </tr>
        
  </table>


NewBean
public class NewBean  implements Serializable {
   
    public String name;
    public int id;

    public NewBean() {
        name = null;
    }

    public void setName( String name ) {
        this.name = name;
    }

          public String getName() {
        return name;
    }
         
          public void setId(int id)
          {
           this.id = id;  
         
          }
         
         
          public int getId()
          {
          return id;
          }
}


AdminServlet(containing LIST_Add method)
public void doGet(HttpServletRequest request, HttpServletResponse response) //Process incoming get request
            throws ServletException, IOException
    {
        doPost(request, response);
         HttpSession session = request.getSession();
        NewBean myBean = (NewBean)session.getAttribute("team");

    }

    public void doPost(HttpServletRequest request, HttpServletResponse response) //Process incoming post request
            throws ServletException, IOException
    {
        String action = findAction(request); //identify which action has been requested

       if (ACTION_LIST_ADD.equals(action))
   {
       String newName = request.getParameter("Name");
       if (isValidString(newName))
       {

            try
            {
                listAdd(newName);
            }
            catch (SQLException e)
          {
               e.printStackTrace();
            }

         }

   }


private void listAdd(String newTeam) throws SQLException   //process Add request from browser
   {
         FootyManager manager = null; //create instance of class
           
         
           

         try

         {
               manager = getFootyManager();  //call method to get connection
               manager.addNewTeamToList(new Team(1, newTeam)); //pass parameters to method
         }

         catch (SQLException e)
                           {
                                 e.printStackTrace();
                      }

         finally
         {
               if (manager != null)
               {
                     manager.releaseResources();
               }

         }

   }

Any ideas guys?



Styx218Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ManishLeadCommented:
First I think u should move your logic written in get method to post method.
And call doPost method (As you are already calling..)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ManishLeadCommented:
>> String newName = request.getParameter("Name");
String newName = request.getParameter("name");//text box name...
0
Mayank SAssociate Director - Product EngineeringCommented:
What is the problem you are facing? Any errors exceptions or unexpected results
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Styx218Author Commented:
What i am trying to do is to add to database when  i click on "Add" but i am getting http error 404

" The requested resource (/MyWeb/team) is not available."
0
Mayank SAssociate Director - Product EngineeringCommented:
have you defined a URL pattern team for some servlet in your web.xml?
0
ManishLeadCommented:
Do you have any servlet having name "name"?
0
Styx218Author Commented:
Hi, Thanks for your suggesstions guys,

I have a servlet pattern as below in web.xml

 <servlet-name>AdminServlet</servlet-name>
 <url-pattern>/footballexample</url-pattern>

My form action is as such in index.jsp

<FORM action = "com.football.AdminServlet" method="POST">
      
      <input type="hidden" name="ACTION" value="LIST_ADD" />
      <tr>
        <td colspan="2"><b>Add new Team</b></td>
        <td><input name="name" type="text" size="20"  /></td>
        <td><input name="ADD" type="submit" value="Add" /></td>
        <td>&nbsp;</td>
      </tr>

Will this work? I am trying to pass to servlet, which passes request to another class to add to database and then redisplay the index.jsp with the updated information in the dataase

// RequestDispatcher rd = getServletContext().getRequestDispatcher("/index.jsp");
   // rd.forward(request, response);

is contained within my list_add  method within the database but request is returning error "cannot find symbol"

I am aware this topic has been going on for a while but i hve no where else to turn to with this.Thanks again for your help
0
Styx218Author Commented:
"is contained within my list_add  method within the database "

i meant within the servlet sorry
0
Mayank SAssociate Director - Product EngineeringCommented:
>> cannot find symbol"

For which one?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.