Discussions

Web tier: servlets, JSP, Web frameworks: How to add new parameters to request object

  1. How to add new parameters to request object (2 messages)

    Hi,
    it is possible to add new parameters to request object when using jsp pages
    <jsp:forward ...
      <jsp:param ..

    but there is no way that I know to do the same thing in servets while forwarding the request to another page. Should not there be a way of doing this?
  2. There is no way to add request parameters to a HttpServletRequest object. This allows the servlet engines to optimize how they handle request parameters.

    My suggestions are:

    1) Pass data in the forward operation in other ways, such as request.setAttribute(). You can even use alternate logic to check both request parameters and request attributes:

    <%
    String data = request.getParameter("data");
    if (data == null) {
      data = request.getAttribute("data");
    }

    2) If this really won't work, you can use a Servlet 2.3 HttpServletRequestWrapper (or some custom variation on this if you are using Servet 2.2), but this is probably more trouble than it is worth.
  3. thanks a lot for your care,
    using a wrapper we solved the problem but I believe that current servlet spesifications lacks such functionality and should be added to HttpServletRequest interface for the comming spesification releases.