0

Here is my jsp

<form action = "first"  > <!-- first servlet -->

    <select name="loginAs">
    <option>Fan</option>
    <option>Club Member</option>
    <option>Admin</option>
    </select>
</form>

Here is my servlet :

protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {

    String c = req.getParameter("loginAs");
}

but it is still showing as null when I use c

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Fakipo
  • 182
  • 2
  • 17

1 Answers1

2

You should add value attributes to your options :

<form action="first"  > <!-- first servlet -->
    <select name="loginAs">
        <option value="Fan">Fan</option>
        <option value="ClubMember">Club Member</option>
        <option value="Admin">Admin</option>
    </select>
</form>
baitmbarek
  • 2,440
  • 4
  • 18
  • 26