Search code examples
javaurlgetparameter

Take out parameter from url


I have a very long url with numbers of parameter like

http://localhost:8080/BUUK/dbcc?dssin=9371062001&roundid=JS&KIPL=02&PLATFORM=1&FREQUENCY=2&DRBEARER=1&BUYTYPE=1&EUP=12&TID=72123456435653654&SHORTCODE=54300&ADCODE=234rfdfsf&Buytag=3&Checkpoint=5,6,7&CHARGEMODEL=complete&restbalance=1

I want retrieve all the parameter from this url.

I was wondering if i can use request.getParamter("restbalance");

I will provide more info if required. Thanks


Solution

  • For each request your web server more precisely your web container creates a two object request and response.

    HttpServletRequest and HttpServletResponse

    The servletcontainer is attached to a webserver which listens on HTTP requests on a certain port number, which is usually 80. When a client (user with a webbrowser) sends a HTTP request, the servletcontainer will create new HttpServletRequest and HttpServletResponse objects and pass it through the methods of the already-created Filter and Servlet instances whose url-pattern matches the request URL, all in the same thread.

    The request object provides access to all information of the HTTP request, such as the request headers and the request body. The response object provides facility to control and send the HTTP response the way you want, such as setting headers and the body (usually with HTML content from a JSP file). When the HTTP response is committed and finished, then both the request and response objects will be trashed.

    request.getParameter("request_param"); will give you request_param value. So there is nothing to get surprise accessing request parameter from request object