0

I have Servlet which rotates me some value http://localhost:666/sg/queue?q=21343434

I want to get the value q

@WebServlet("/queue")
public class QueueServlet extends HttpServlet {
    private List<String> queue;
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        queue = new ArrayList<String>();
        queue.add("12324543254235");
        out.print(queue.size());
        out.print(request.getAttribute("q").toString());
    }
}

but when I write out.print(request.getAttribute("q").toString()); nothing is displayed

and when I write out.print(request.getQueryString()); displayed q=21343434

but I need to get only the very value q

1 Answers1

1

Use request.getParameter() to get param of url, the getAttribute() is used to get data of posted request.

Mavlarn
  • 3,807
  • 2
  • 37
  • 57