Hooke Kevin wrote:
>
> Hi - I am trying to call a servlet from a jsp page to perfrom a simple
> server-side include.
>
> I can successfully call the servlet, but any parameters I pass do not seem to
> make it into the servlet.
>
> I would like to use the following:
>
> <jsp:include page="/servlet/UIService?request_type=blank_dropdown"
> flush="true"/>
>
> This successfully calls the servlet, but the parameter passed in the url to the
> servlet are 'lost'... ie they don't seem to get passed into the servlet - if I
> try to do a request.getParameter("request_type"), it returns null.
>
> (If I call the servlet directly via a URL in my browser it works ok)

In JSP 1.0 (Servlet 2.1) it's not guaranteed that a query string in a URL
works. In JSP 1.1 (Servlet 2.2) it's defined to work, but there are very
few JSP 1.1 containers available at this point.

If you're using a JSP 1.0 container, the safest way is to use request attributes
as opposed to parameters. Add the attribute to theh request before calling
<jsp:include>:

  <% request.setAttribute("request_type", "blank_dropdown"); %>
  <jsp:include page="/servlet/UIService" flush="true"/>

The get it in the servlet with:

  String reqType = (String) request.getAttribute("request_type");

> I have also tried using the RequestDispather form my jsp code to do the same:
>
> <%
> RequestDispatcher dispatcher =
>             application.getRequestDispatcher("/servlet/UIService");
>
> request.setAttribute("request_type", "blank_dropdown");
>
> dispatcher.include(request, response);
> %>
>
> - but the same happens here too.

See above; when you pass a value as an attribute you must use getAttribute()
as opposed to getParameter().

--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to