Samurai Edge Posted December 10, 2006 Share Posted December 10, 2006 (edited) I need to "know how to have more than 1 button in 1 form, yet all buttons invoke the same servlet".That sentence was given as a clue from my teacher, but common sense is that when the different buttons call the same servlet, they should be calling different methods. It's stupid if there are 10 buttons and they do the same thing.Here are parts of codes I normally use <form method="get" action="Servlet1"><input name="button1" type="submit" value="Submit"></form><form method="get" action="Servlet2"><input name="button2" type="submit" value="Submit"></form> button1 will call Servlet1 while button2 will call Servlet2. In Servlet1 and Servlet2, there are only two methods, doGet and processRequest. The following are an example. public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {processRequest(request, response);} private void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{//simple codes that does only one task} And my classmate told me that another teacher gave another clue that the test have more than one JSPs, one Java Bean but ONLY 1 servlet. So I guess the servlet must have a lot of methods to do different tasks. I know the the codes for the jsp side, but I don't know how to differentiate them on the servlets.<form method="get" action="Servlet1"><input name="button1" type="submit" value="Submit"><input name="button2" type="submit" value="Submit"></form> EDIT: Just figure it out I'm ready for my test!!! Edited December 12, 2006 by Samurai Edge Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now