import javax.servlet.http.HttpServletRequest; public class ExampleServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) { String queryString = request.getQueryString(); //gets the query string from the request if (queryString == null) { response.getWriter().println("No query string found."); //prints a message if there is no query string } else { response.getWriter().println("Query string: " + queryString); //prints the query string } } }The HttpServletRequest class is part of the javax.servlet package, which is used to build Web-based applications.