Dinesh Somasundram wrote:
>
> Dear Sir,
>
> That's right. I am using the <jsp:include> before the redirect. The reason
> is that in the include, I need to pass a parameter. Is that a way to pass
> the parameter if I were to use the include page directive?

No matter if you use the include action or the include directive, the
included page has access to the same request parameters as the main
page. So if the parameter you need is sent as a request parameter, just
get it the same way as in the original page (e.g. using setProperty for
a bean or request.getParameter() in a scriptlet).

If you need to pass on a value that is not a request parameter to a
page that is included with the include directive, you can use a number
of approaches, for instance:
1) Use the "page scope", e.g. use useBean to create a bean that carries
   the value, or pageContext.setAttribute("name", "value") in a scriptlet.
   Since a file included with the directive is merged with the original
   file before translation to a servlet, it shares the page scope with
   the original file.
2) Declare a variable in the main file and assign it the value using a
   scriptlet: <% String hello = "Hello World" %>. Again, since the
   included file becomes part of the same servlet, you can access the
   variable directly in the included file: <%= hello %> or
   <% String newString = hello + ". How are you?" %>

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com
Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to