Reputation: 139
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
Upvotes: 0
Views: 159
Reputation: 3883
Use request.getParameter() to get param of url, the getAttribute() is used to get data of posted request.
Upvotes: 1