3

i am trying to pass a string from my jsp to the servlet via href. I use this

<a href="MyServlet?select=title1"> Title1 </a>

then in the servlet i am trying to get the value of the select with this

String s = request.getParameter("select");

But it returns null. Why is that? Thank you!

EDIT I post the code of the servlet

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        String userOption = request.getAttribute("select");
        System.out.println("Select is:" + userOption);
        //in the console i get: Select is:null
yaylitzis
  • 4,991
  • 15
  • 56
  • 98

1 Answers1

0

That should not be String userOption = request.getAttribute("select");

Please understand that attributes are not parameters

It should be String userOption = request.getParameter("select");

Prasad Kharkar
  • 13,107
  • 3
  • 36
  • 55