Solved

jsp:include with params

Posted on 2004-10-22
485 Views
Last Modified: 2013-11-18
Hi all experts out there,

Say i got this page,a.jsp
....
 <jsp:include page="../../util/grid.jsp">
    <jsp:param name="__header" value="headerValues"/>
 </jsp:include>
....
and in grid.jsp I tried getting the __header value by,
<%
System.out.println("header param:::>"+request.getParameter("__header"));
%>

the problem is request.getParameter("__header") return a null value.
What is actually the problem...?

Thanks in advance


0
Question by:sunmaster
    8 Comments
     
    LVL 35

    Expert Comment

    by:TimYates
    Try:

     <jsp:include page="../../util/grid.jsp" flush="true">
        <jsp:param name="__header" value="headerValues"/>
     </jsp:include>

    0
     
    LVL 1

    Author Comment

    by:sunmaster
    tried...
    but still cannot...
    any other suggestion...?
    0
     
    LVL 35

    Expert Comment

    by:TimYates
    There must be something wrong with your code...  because that should work...

    Try:

    <%
      out.println( "header param:::>" + request.getParameter("__header") ) ;
    %>

    to make sure it appears in your browser...  

    And make sure you have the same number of underscores in both pages (2)

    Tim
    0
     
    LVL 1

    Author Comment

    by:sunmaster
    still the same...
    any ideas... Btw, I am using tomcat 5. if it any help... or is there any thing i need to set in web.xml...? or other thing else....?

    and what is flush="true" use for...?
    0
     
    LVL 1

    Author Comment

    by:sunmaster
    hi TimYates,

      I found out that somebody else also have this same problem from this site,
    http://list.jahia.org/dev_list/msg00498.html.

      But i don't understand the sollution. Perhaps you can help me...?Thanks and i Really need your help.

    sunmaster
    0
     
    LVL 35

    Expert Comment

    by:TimYates
    What version of Tomcat are you running?

    This is starting to sound like a bug :-(
    0
     
    LVL 1

    Author Comment

    by:sunmaster
    hi,

    i am using tomcat 5, and my web.xml is something like this,

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
      <context-param>
        <param-name>FI_CODE</param-name>
        <param-value>001912</param-value>
      </context-param>
      <context-param>
        <param-name>QUICK_LINK_NUM</param-name>
        <param-value>10</param-value>
      </context-param>
      <description>
          eMCMS Application
        </description>
      <display-name>eMCMS Application</display-name>
      <context-param>
        <param-name>CACHE_LOCATION</param-name>
        <param-value>D:/Tomcat/webapps/emcms/cache</param-value>
      </context-param>

      <filter>
        <filter-name>CheckPoint</filter-name>
        <filter-class>my.com.eprotea.emcms.filters.TaskCheckPointFilter</filter-class>
      </filter>
      <filter>
        <filter-name>XMLCacheFilter</filter-name>
        <filter-class>my.com.eprotea.emcms.cache.XMLCacheFilter</filter-class>
      </filter>
    <!--  <filter>
        <filter-name>Compression Filter</filter-name>
        <filter-class>compressionFilters.CompressionFilter</filter-class>
        <init-param>
          <param-name>compressionThreshold</param-name>
          <param-value>10</param-value>
        </init-param>
        <init-param>
          <param-name>debug</param-name>
          <param-value>1</param-value>
        </init-param>
      </filter>-->
      <filter>
        <filter-name>HttpPoster</filter-name>
        <filter-class>my.com.eprotea.emcms.filters.HTTPParameterParser</filter-class>
        <init-param>
          <param-name>XMLLocation</param-name>
          <param-value>D:/Tomcat/webapps/emcms/xml</param-value>
        </init-param>
        <init-param>
          <param-name>MsgHeaderName</param-name>
          <param-value>MsgHeader.xml</param-value>
        </init-param>
        <init-param>
          <param-name>RequestHeaderName</param-name>
          <param-value>RequestHeader.xml</param-value>
        </init-param>
        <init-param>
          <param-name>ResponseHeaderName</param-name>
          <param-value>ResponseHeader.xml</param-value>
        </init-param>
        <init-param>
          <param-name>DEBUG</param-name>
          <param-value>0</param-value>
        </init-param>
        <init-param>
          <param-name>READ_LOOPS</param-name>
          <param-value>5000</param-value>
        </init-param>
        <init-param>
          <param-name>WRITE_LOOPS</param-name>
          <param-value>5000</param-value>
        </init-param>
        <init-param>
          <param-name>XMLGatewayLocation</param-name>
          <param-value>http://192.168.2.104:8080/emcms-gateway/XMLGatewayServlet</param-value>
        </init-param>
      </filter>
      <filter>
        <filter-name>SignOnFilter</filter-name>
        <filter-class>my.com.eprotea.security.SignOnFilter</filter-class>
      </filter>
      <filter>
        <filter-name>XMLSortFilter</filter-name>
        <filter-class>my.com.eprotea.emcms.filters.XMLSortFilter</filter-class>
      </filter>
      <filter>
        <filter-name>Formatter</filter-name>
        <filter-class>my.com.eprotea.emcms.filters.Formatter</filter-class>
      </filter>

    <!--  <filter-mapping>
        <filter-name>Compression Filter</filter-name>
        <url-pattern>*.jsp</url-pattern>
      </filter-mapping>-->
      <filter-mapping>
        <filter-name>CheckPoint</filter-name>
        <url-pattern>*.jsp</url-pattern>
      </filter-mapping>
      <filter-mapping>
        <filter-name>XMLCacheFilter</filter-name>
        <url-pattern>*.jsp</url-pattern>
      </filter-mapping>
      <filter-mapping>
        <filter-name>SignOnFilter</filter-name>
        <url-pattern>/RSE500MN</url-pattern>
      </filter-mapping>
      <filter-mapping>
        <filter-name>HttpPoster</filter-name>
        <url-pattern>*.jsp</url-pattern>
      </filter-mapping>
      <filter-mapping>
        <filter-name>XMLSortFilter</filter-name>
        <url-pattern>*.jsp</url-pattern>
      </filter-mapping>  
      <filter-mapping>
        <filter-name>HttpPoster</filter-name>
        <url-pattern>/RSE500MN</url-pattern>
      </filter-mapping>
      <filter-mapping>
        <filter-name>XMLSortFilter</filter-name>
        <url-pattern>*.jsp</url-pattern>
      </filter-mapping>
        <filter-mapping>
        <filter-name>Formatter</filter-name>
        <url-pattern>/*</url-pattern>
      </filter-mapping>
      <servlet>
        <servlet-name>RSE500MN</servlet-name>
        <servlet-class>my.com.eprotea.signon.ECMSSignOn</servlet-class>
      </servlet>
      <servlet>
        <servlet-name>NewServlet</servlet-name>
        <servlet-class>my.com.eprotea.signon.NewServlet</servlet-class>
      </servlet>
      <servlet>
        <servlet-name>servletQuickLnk</servlet-name>
        <servlet-class>my.com.eprotea.emcms.maint.QuickLnk</servlet-class>
      </servlet>
      <servlet>
        <servlet-name>GenFunctions</servlet-name>
        <servlet-class>my.com.eprotea.emcms.maint.GenFunctions</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>RSE500MN</servlet-name>
        <url-pattern>/RSE500MN</url-pattern>
      </servlet-mapping>
      <servlet-mapping>
        <servlet-name>NewServlet</servlet-name>
        <url-pattern>/NewServlet</url-pattern>
      </servlet-mapping>
      <servlet-mapping>
        <servlet-name>servletQuickLnk</servlet-name>
        <url-pattern>/QuickLnk</url-pattern>
      </servlet-mapping>
      <servlet-mapping>
        <servlet-name>GenFunctions</servlet-name>
        <url-pattern>/GenFunctions</url-pattern>
      </servlet-mapping>
      <welcome-file-list>
        <welcome-file>/jsp/index.jsp</welcome-file>
        <welcome-file>/index.jsp</welcome-file>
      </welcome-file-list>
      <error-page>
        <exception-type>java.lang.Exception</exception-type>
        <location>/gen/ErrorPage.jsp</location>
      </error-page>
      <error-page>
        <exception-type>javax.security.auth.login.LoginException</exception-type>
        <location>/index.jsp</location>
      </error-page>
      <security-constraint>
        <display-name>Example Security Constraint</display-name>
        <web-resource-collection>
          <web-resource-name>Protected Area</web-resource-name>
          <!-- Define the context-relative URL(s) to be protected -->
          <url-pattern>/iss/*</url-pattern>
          <url-pattern>/acq/*</url-pattern>
          <!-- <url-pattern>/gen/*</url-pattern> -->
          <url-pattern>/xml/*</url-pattern>
          <url-pattern>/maint/*</url-pattern>
          <url-pattern>/util/*</url-pattern>
          <url-pattern>/index.jsp</url-pattern>
          <!--<url-pattern>/*</url-pattern>-->
          <!-- If you list http methods, only those methods are protected -->
          <http-method>DELETE</http-method>
          <http-method>GET</http-method>
          <http-method>POST</http-method>
          <http-method>PUT</http-method>
        </web-resource-collection>
        <auth-constraint>
          <!-- Anyone with one of the listed roles may access this area -->
          <role-name>emcms</role-name>
        </auth-constraint>
      </security-constraint>
      <!-- Default login configuration uses form-based authentication -->
      <login-config>
        <auth-method>FORM</auth-method>
        <realm-name>emcmsRealm</realm-name>
        <form-login-config>
          <form-login-page>/signon.jsp</form-login-page>
          <form-error-page>/gen/ErrorPage.jsp</form-error-page>
        </form-login-config>
      </login-config>
      <!-- Security roles referenced by this web application -->
      <security-role>
        <role-name>emcms</role-name>
      </security-role>
    </web-app>


    but if i change my web.xml to

    <?xml version="1.0" encoding="UTF-8"?>

    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
           version="2.4">
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
        <welcome-file-list>
          <welcome-file>
                index.jsp
            </welcome-file>
          <welcome-file>
                index.html
            </welcome-file>
          <welcome-file>
                index.htm
            </welcome-file>
        </welcome-file-list>
    </web-app>


    it WORKS!!! but this is not the web.xml that i want. Can you point out what wrong with my web.xml or something wrong with the filters...?

    Please help,
    Thanks,
    sunmaster
    0
     
    LVL 35

    Accepted Solution

    by:
    All of these filters:

      <filter-mapping>
        <filter-name>CheckPoint</filter-name>
        <url-pattern>*.jsp</url-pattern>
      </filter-mapping>
      <filter-mapping>
        <filter-name>XMLCacheFilter</filter-name>
        <url-pattern>*.jsp</url-pattern>
      </filter-mapping>
      <filter-mapping>
        <filter-name>HttpPoster</filter-name>
        <url-pattern>*.jsp</url-pattern>
      </filter-mapping>
      <filter-mapping>
        <filter-name>XMLSortFilter</filter-name>
        <url-pattern>*.jsp</url-pattern>
      </filter-mapping>  
      <filter-mapping>
        <filter-name>XMLSortFilter</filter-name>
        <url-pattern>*.jsp</url-pattern>
      </filter-mapping>
        <filter-mapping>
        <filter-name>Formatter</filter-name>
        <url-pattern>/*</url-pattern>
      </filter-mapping>

    Will get called before your JSP...  Maybe one of them is stripping the parameters?  Can you try commenting them all out (it should work) then add them in one by one...  At a certain point, it will probably stop working...  then the last filter you added in is the one to look at...

    Make sure it's chaining right...and not stripping request parameters

    That is, assuming you have the code for it...

    Tim
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
    Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    913 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now