"Hernandez, Rey" wrote:
>
> Think of included JSP files as being part of the file the include command is
> in.  If you want the included file to see something, like a string, just
> make the String declaration before the include command and then use that
> variable in the included file.
>
> Example.
>
> Test1.jsp:
> ...
> <%
> String username = "Rey";
> String editable = "ok";
> %>
> <jsp:include page="Test.jsp" flush="true" />
> ...
>
> Test.jsp:
> ...
> username = <%= username %><br>
> editable = <%= editable %>
> ...

What you describe is true only when you use the include directive
(i.e. <%@ include file="somefile" %>), not when you use the include
action (i.e. <jsp:include page="somepage" flush="true">).

When you use the include action, the JSP page of servlet specified
by the "page" attribute is executed and the response body is included.
The target JSP/servlet has access to all original parameters and you
can also add new parameters:

  <jsp:include page="Test.jsp" flush="true">
    <jsp:param name="username" value="eric"/>
    <jsp:param name="editable" value="ok" />
  </jsp:include>

The only mistake in the original mail in this thread is that the
syntax for the <jsp:include> action element is not correct. You
must not use the "/>" version of the tag when the element has a
body, as it has in this case.

In the target JSP/servlet, you access the parameters the same way
no matter if they are original or added, using getParameter() et al.

Hans

> -----Original Message-----
> From: Tom Yang [mailto:[EMAIL PROTECTED]]
> Sent: Friday, November 03, 2000 2:03 PM
> To: [EMAIL PROTECTED]
> Subject: How to get the parameters passed to included jsp file?
>
> Hi all:
>   I am trying to use the
>   <jsp:include>
>   to include another jsp file. I want to pass a few parameters to the
> included file. I used the statements like the following:
>
> <jsp:include page="Test.jsp" flush="true"/>
>   <jsp:param name="username" value="eric"/>
>   <jsp:param name="editable" value="ok" />
> </jsp:include>
>
> But I don't know how I can get the parameters in the Test.jsp included. I
> tried to use the statement
>
>   String User_Name = request.getParameter("username");
>
>   and User_Name is null.
>
>   I also tried to use the variable username directly in the Test.jsp, it say
> it is an undefined varaible. Now how can I retrieve the value of the vaiable
> userename passed so that I can use it in the file Test.jsp included?
>   Any help will be greately appreciated. Thanks in advance!
>
> Tom
>
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
> Share information about yourself, create your own public profile at
> http://profiles.msn.com.
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> 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
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> 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


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

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
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