2

I have a .jsp page that have 1 textbox and 4 button like this image. My project creating ms word document report. It takes datas from access database. enter image description here

I want to run different servlets each button click but I don't know how to do it? Is there any idea?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
mustafa53
  • 113
  • 2
  • 14

1 Answers1

1

You can do this in many ways here is an example

 <form action="MainServlet" method="Post">
        SOME Name: <input type="text" name="someName" size="20">
        <br><br>
        <input type="submit" name="first" value="FirstServlet">
        <input type="submit" name="second" value="SecondServlet">
        <input type="submit" name="third" value="ThirdServlet">
        <input type="submit" name="fourth" value="FourthServlet">
    </form>

    with the following in MainServlet

    String sometext = request.getParameter("someName"); // your text box value
    if (request.getParameter("first") != null) {
        // Invoke FirstServlet's job here.
    } else if (request.getParameter("second") != null) {
        // Invoke SecondServlet's job here.
    } else if (request.getParameter("third") != null) {
        // Invoke ThirdServlet's job here.
    } else if (request.getParameter("fourth") != null) {
        // Invoke FourthServlet's job here.
    }
Seshidhar G
  • 265
  • 1
  • 9