LearnFast.Ninja

Java query string example

How to use Java servlet query string parameters tutorial. In Java you get query parameter from url using getParameter function from the HttpServletResponse object. The parameters are contained in the query string or posted form data.

Working Example Code:

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

       String id = request.getParameter("id");

       PrintWriter oPrintWriter = response.getWriter();

       oPrintWriter.print(id);

}


Result:


Tags

java

servlet query-string